|
@@ -21,10 +21,23 @@
|
|
|
##############################################################################
|
|
|
|
|
|
from openerp import models, api
|
|
|
+from pytz import timezone
|
|
|
+from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT, DEFAULT_SERVER_DATE_FORMAT
|
|
|
+from datetime import datetime,timedelta
|
|
|
+
|
|
|
+DATE_FORMAT = '%Y-%m-%d'
|
|
|
+# return datetime.now(self.get_timezone()).strftime(DATE_FORMAT)
|
|
|
|
|
|
class SaleOrder(models.Model):
|
|
|
_inherit = 'sale.order'
|
|
|
|
|
|
+ ''' Timezone '''
|
|
|
+ def get_timezone(self):
|
|
|
+ return timezone(self._context.get('tz') or self.env.user.tz)
|
|
|
+
|
|
|
+ def _convert_str_to_datetime(self, date):
|
|
|
+ return datetime.strptime(date,DEFAULT_SERVER_DATETIME_FORMAT)
|
|
|
+
|
|
|
@api.multi
|
|
|
def order_process_now(self):
|
|
|
"""
|
|
@@ -35,7 +48,9 @@ class SaleOrder(models.Model):
|
|
|
inv_id = sale.action_invoice_create()
|
|
|
if inv_id:
|
|
|
inv = self.env['account.invoice'].browse(inv_id)
|
|
|
- inv.write({'date_invoice':sale.date_confirm})
|
|
|
+ date = self._convert_str_to_datetime(sale.date_order)
|
|
|
+ date = date.strftime(DATE_FORMAT)
|
|
|
+ inv.write({'date_invoice':date})
|
|
|
inv.signal_workflow('invoice_open')
|
|
|
for picking in sale.picking_ids:
|
|
|
picking.force_assign()
|