From 86b7ce81a9ee8d6431817d9f4019b20401ed1988 Mon Sep 17 00:00:00 2001 From: Roman Widmann Date: Wed, 7 Mar 2018 11:38:31 +0100 Subject: [PATCH] =?UTF-8?q?Fall=204979,=20Mehrere=20Provisionsempf=C3=A4ng?= =?UTF-8?q?er?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ext/custom-addons/dp_custom/__manifest__.py | 1 + .../dp_custom/models/__init__.py | 1 + ext/custom-addons/dp_custom/models/account.py | 21 -------- .../dp_custom/models/commission_account.py | 13 +++++ .../dp_custom/models/res_partner.py | 7 +-- .../dp_custom/security/ir.model.access.csv | 2 + .../dp_custom/views/commission_account.xml | 50 +++++++++++++++++++ .../dp_custom/views/res_partner_views.xml | 2 +- 8 files changed, 69 insertions(+), 28 deletions(-) create mode 100644 ext/custom-addons/dp_custom/models/commission_account.py create mode 100644 ext/custom-addons/dp_custom/views/commission_account.xml diff --git a/ext/custom-addons/dp_custom/__manifest__.py b/ext/custom-addons/dp_custom/__manifest__.py index 1b16c770..e8c52a18 100644 --- a/ext/custom-addons/dp_custom/__manifest__.py +++ b/ext/custom-addons/dp_custom/__manifest__.py @@ -38,6 +38,7 @@ 'sale_partner_incoterm', ], 'data': [ + 'views/commission_account.xml', 'wizards/wizard_confirm_production.xml', 'security/security.xml', 'data/dp_custom_data.xml', diff --git a/ext/custom-addons/dp_custom/models/__init__.py b/ext/custom-addons/dp_custom/models/__init__.py index 22281ea6..165b0fc5 100644 --- a/ext/custom-addons/dp_custom/models/__init__.py +++ b/ext/custom-addons/dp_custom/models/__init__.py @@ -30,3 +30,4 @@ from . import material_type from . import product from . import ir_attachment from . import account +from . import commission_account diff --git a/ext/custom-addons/dp_custom/models/account.py b/ext/custom-addons/dp_custom/models/account.py index 15fae72a..7b5eaa6e 100644 --- a/ext/custom-addons/dp_custom/models/account.py +++ b/ext/custom-addons/dp_custom/models/account.py @@ -67,24 +67,3 @@ class AccountInvoice(models.Model): if line.uom_id == self.env.ref('product.product_uom_unit'): # wenn die Mengeneinheit Stk. ist num_items += line.quantity record.num_items = num_items - - -class AccountInvoiceReport(models.Model): - _inherit = "account.invoice.report" - - commission_user_id = fields.Many2one('res.users', string='Provisionsempfänger', readonly=True) - - def _select(self): - res = super(AccountInvoiceReport, self)._select() - res += ', sub.commission_user_id as commission_user_id' - return res - - def _sub_select(self): - res = super(AccountInvoiceReport, self)._sub_select() - res += ', partner.commission_user_id' - return res - - def _group_by(self): - res = super(AccountInvoiceReport, self)._group_by() - res += ', partner.commission_user_id' - return res diff --git a/ext/custom-addons/dp_custom/models/commission_account.py b/ext/custom-addons/dp_custom/models/commission_account.py new file mode 100644 index 00000000..70ed5864 --- /dev/null +++ b/ext/custom-addons/dp_custom/models/commission_account.py @@ -0,0 +1,13 @@ +# Copyright 2018-Today datenpol gmbh () +# License OPL-1 or later (https://www.odoo.com/documentation/user/11.0/legal/licenses/licenses.html#licenses). + +from odoo import api, fields, models, _ + + +class CommissionAccount(models.Model): + _name = 'commission.account' + _description = 'Provisionsempfänger Objekt' + _order = "sequence, name" + + name = fields.Char(string="Bezeichnung", required=True) + sequence = fields.Integer(string="Sequenznummer") diff --git a/ext/custom-addons/dp_custom/models/res_partner.py b/ext/custom-addons/dp_custom/models/res_partner.py index de2ef10b..699eaa27 100644 --- a/ext/custom-addons/dp_custom/models/res_partner.py +++ b/ext/custom-addons/dp_custom/models/res_partner.py @@ -67,18 +67,13 @@ class Partner(models.Model): date_vat_check = fields.Date(string='Datum der letzten UID-Prüfung') collective_bill = fields.Boolean(string='Sammelrechnung', default=True) country_id = fields.Many2one('res.country', string='Country', ondelete='restrict', default=_default_country_id) - commission_user_id = fields.Many2one('res.users', string='Provisionsempfänger') + commission_account_ids = fields.Many2many(comodel_name='commission.account', string='Provisionsempfänger') _sql_constraints = [ ('ref_uniq', 'unique(ref)', 'Die Interne Referenz muss eindeutig sein'), ('portal_id_uniq', 'unique(portal_id)', 'Die Portal-ID muss eindeutig sein') ] - @api.model - def _commercial_fields(self): - res = super(Partner, self)._commercial_fields() - return res + ['commission_user_id'] - @api.one @api.constrains('is_company', 'vat') def _check_unique_vat(self): diff --git a/ext/custom-addons/dp_custom/security/ir.model.access.csv b/ext/custom-addons/dp_custom/security/ir.model.access.csv index 66706694..d50de6a7 100644 --- a/ext/custom-addons/dp_custom/security/ir.model.access.csv +++ b/ext/custom-addons/dp_custom/security/ir.model.access.csv @@ -9,3 +9,5 @@ access_product_xcategory_user,access_product_xcategory_user,model_product_xcateg access_product_xcategory_sales_manager,access_product_xcategory_sales_manager,model_product_xcategory,sales_team.group_sale_manager,1,1,1,1 sale.access_sale_order_manager,sale.order.manager,model_sale_order,sales_team.group_sale_manager,1,1,1,0 access_sale_order_unlink,sale.order.unlink,model_sale_order,dp_custom.group_allow_delete_so_drafts,1,1,1,1 +access_commission_account_user,access_commission_account_user,model_commission_account,base.group_user,1,0,0,0 +access_commission_account_manager,access_commission_account_manager,model_commission_account,sales_team.group_sale_manager,1,1,1,1 diff --git a/ext/custom-addons/dp_custom/views/commission_account.xml b/ext/custom-addons/dp_custom/views/commission_account.xml new file mode 100644 index 00000000..e8378013 --- /dev/null +++ b/ext/custom-addons/dp_custom/views/commission_account.xml @@ -0,0 +1,50 @@ + + + + + + + view_commission_account_form + commission.account + +
+ + + + + + +
+
+
+
+ + + view_commission_account_tree + commission.account + + + + + + + + + + Provisionsempfänger + commission.account + tree,form + [] + {} + + + + + Provisionsempfänger + + + + + +
diff --git a/ext/custom-addons/dp_custom/views/res_partner_views.xml b/ext/custom-addons/dp_custom/views/res_partner_views.xml index 1a3b0e67..098519b9 100644 --- a/ext/custom-addons/dp_custom/views/res_partner_views.xml +++ b/ext/custom-addons/dp_custom/views/res_partner_views.xml @@ -59,7 +59,7 @@ - +