From 27f19ad3656ee6fd92b018d11956cfee59348107 Mon Sep 17 00:00:00 2001 From: Ahmed Aly Date: Tue, 5 Dec 2017 11:24:49 +0100 Subject: [PATCH] Feedback 1143: SST-11: neues Feld in Zahlungsbedingungen --- ext/custom-addons/dp_custom/models/account.py | 6 ++++++ ext/custom-addons/dp_custom/models/res_partner.py | 12 +++++++++++- ext/custom-addons/dp_custom/views/account_views.xml | 13 +++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/ext/custom-addons/dp_custom/models/account.py b/ext/custom-addons/dp_custom/models/account.py index 246e16d2..4e715179 100644 --- a/ext/custom-addons/dp_custom/models/account.py +++ b/ext/custom-addons/dp_custom/models/account.py @@ -31,3 +31,9 @@ class AccountInvoiceLine(models.Model): if vals.get('product_id', False) and not vals.get('intrastat_id', False): vals.update(intrastat_id=self.env['product.template'].browse(vals['product_id']).intrastat_id.id) return super(AccountInvoiceLine, self).create(vals) + + +class AccountPaymentTerm(models.Model): + _inherit = 'account.payment.term' + + code = fields.Char(string='Code') diff --git a/ext/custom-addons/dp_custom/models/res_partner.py b/ext/custom-addons/dp_custom/models/res_partner.py index aca88d26..7e75783f 100644 --- a/ext/custom-addons/dp_custom/models/res_partner.py +++ b/ext/custom-addons/dp_custom/models/res_partner.py @@ -124,6 +124,15 @@ class Partner(models.Model): else: raise ValidationError(_("Die Branche \'%s\' kann nicht zugeordnet werden" % vals['partner_sector_id'])) + if vals.get('property_payment_term_id', False): + payment_term = self.env['account.payment.term'].search( + [('code', '=', vals['property_payment_term_id'])]) + if payment_term: + vals['property_payment_term_id'] = payment_term.id + else: + raise ValidationError(_("Die Zahlungsbedingung mit dem Code \'%s\' kann nicht zugeordnet werden" % vals[ + 'property_payment_term_id'])) + return vals @api.model @@ -169,7 +178,8 @@ class Partner(models.Model): }) portal_url = tools.config.get('portal_url') application_id = tools.config.get('portal_secret') - response = requests.post(portal_url + '/api/v1/set-discounts/?secret=' + application_id, data=json.dumps(data)) + response = requests.post(portal_url + '/api/v1/set-discounts/?secret=' + application_id, + data=json.dumps(data)) if response.status_code != 200: raise ValidationError(_('Rabatt konnte nicht gesetzt werden.')) diff --git a/ext/custom-addons/dp_custom/views/account_views.xml b/ext/custom-addons/dp_custom/views/account_views.xml index b1dc46bc..f97c56ba 100644 --- a/ext/custom-addons/dp_custom/views/account_views.xml +++ b/ext/custom-addons/dp_custom/views/account_views.xml @@ -12,4 +12,17 @@ + + account_payment_term_form_view + account.payment.term + + + + + + + + + +