|
@@ -0,0 +1,35 @@
|
|
|
+# -*- coding: utf-8 -*-
|
|
|
+from openerp import models, fields, api
|
|
|
+
|
|
|
+class SaleOrder(models.Model):
|
|
|
+ _inherit = 'sale.order'
|
|
|
+
|
|
|
+ is_delivery = fields.Boolean(string='Delivery?')
|
|
|
+ delivery_type = fields.Selection([
|
|
|
+ ('local', 'Local'),
|
|
|
+ ('envio', 'Envio al Interior')],
|
|
|
+ string='Tipo de delivery', default='local')
|
|
|
+
|
|
|
+ @api.multi
|
|
|
+ def order_process_now(self):
|
|
|
+ """
|
|
|
+ Confirms order and creates and validates invoice, confirms pickings.
|
|
|
+ """
|
|
|
+ for sale in self:
|
|
|
+ sale.action_button_confirm()
|
|
|
+ inv_id = sale.action_invoice_create()
|
|
|
+ if inv_id:
|
|
|
+ inv = self.env['account.invoice'].browse(inv_id)
|
|
|
+ inv.write({
|
|
|
+ 'is_delivery':self.is_delivery,
|
|
|
+ 'delivery_type':self.delivery_type,
|
|
|
+ })
|
|
|
+
|
|
|
+class AccountInvoice(models.Model):
|
|
|
+ _inherit = 'account.invoice'
|
|
|
+
|
|
|
+ is_delivery = fields.Boolean(string='Delivery?')
|
|
|
+ delivery_type = fields.Selection([
|
|
|
+ ('local', 'Local'),
|
|
|
+ ('envio', 'Envio al Interior')],
|
|
|
+ string='Tipo de delivery', default='local')
|