From c7780a1cc54af4e8b8e18efa7f9f52d125f0709e Mon Sep 17 00:00:00 2001 From: Ahmed Aly Date: Wed, 4 Apr 2018 08:59:05 +0200 Subject: [PATCH] =?UTF-8?q?Fall=205400:=20CR1=20-=20Zahlungsbedingungen=20?= =?UTF-8?q?H=C3=A4ndler?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ext/custom-addons/dp_custom/models/sale.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ext/custom-addons/dp_custom/models/sale.py b/ext/custom-addons/dp_custom/models/sale.py index 43dbccef..714a6b46 100644 --- a/ext/custom-addons/dp_custom/models/sale.py +++ b/ext/custom-addons/dp_custom/models/sale.py @@ -52,6 +52,13 @@ class SaleOrder(models.Model): weight_total = fields.Float(string='Gesamtgewicht', compute='_compute_weight_total') confirmation_nr = fields.Char('Freigabe-Nr.') + @api.multi + @api.onchange('partner_invoice_id') + def _onchange_partner_invoice_id(self): + for record in self: + if record.partner_invoice_id.retail_partner_id: + record.payment_term_id = record.partner_invoice_id.retail_partner_id.property_payment_term_id + @api.multi def _compute_weight_total(self): for record in self: @@ -175,11 +182,14 @@ class SaleOrder(models.Model): order_line_vals = vals.get('order_lines', False) vals = self.remove_not_specified_fields(vals) vals = self.correct_values(vals) + payment_term = partner.property_payment_term_id + if partner.retail_partner_id: + payment_term = partner.retail_partner_id.property_payment_term_id vals.update({ 'partner_id': partner.id, 'fiscal_position_id': partner.property_account_position_id.id, 'user_id': partner.user_id.id, - 'payment_term_id': partner.property_payment_term_id.id, + 'payment_term_id': payment_term.id, 'partner_shipping_id': delivery_partner.id, 'partner_invoice_id': partner.id, 'incoterm': partner.sale_incoterm_id.id