diff --git a/ext/custom-addons/dp_custom/__manifest__.py b/ext/custom-addons/dp_custom/__manifest__.py index e8c5b54a..896995ef 100644 --- a/ext/custom-addons/dp_custom/__manifest__.py +++ b/ext/custom-addons/dp_custom/__manifest__.py @@ -64,6 +64,7 @@ 'views/product_views.xml', 'views/ir_attachment_views.xml', 'views/res_company_views.xml', + 'views/res_users_views.xml', 'security/ir.model.access.csv', ], 'installable': True, diff --git a/ext/custom-addons/dp_custom/models/res_partner.py b/ext/custom-addons/dp_custom/models/res_partner.py index cd5247da..57eb321a 100644 --- a/ext/custom-addons/dp_custom/models/res_partner.py +++ b/ext/custom-addons/dp_custom/models/res_partner.py @@ -78,6 +78,12 @@ class Partner(models.Model): partner_flash = fields.Char() fax = fields.Char(string='Fax') +# make pricelist searchable (store=True) --> code copied from: \ext\odoo\addons\product\models\res_partner.py! + property_product_pricelist = fields.Many2one( + 'product.pricelist', 'Sale Pricelist', compute='_compute_product_pricelist', store=True, required=True, + inverse="_inverse_product_pricelist", company_dependent=False, # NOT A REAL PROPERTY + help="This pricelist will be used, instead of the default one, for sales to the current partner") + _sql_constraints = [ ('ref_uniq', 'unique(ref)', 'Die Interne Referenz muss eindeutig sein'), ('portal_id_uniq', 'unique(portal_id)', 'Die Portal-ID muss eindeutig sein') diff --git a/ext/custom-addons/dp_custom/models/res_users.py b/ext/custom-addons/dp_custom/models/res_users.py index 6c1445b8..6691194d 100644 --- a/ext/custom-addons/dp_custom/models/res_users.py +++ b/ext/custom-addons/dp_custom/models/res_users.py @@ -1,12 +1,14 @@ # 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, models +from odoo import api, models, fields class Users(models.Model): _inherit = 'res.users' + clerk_name = fields.Char('Sachbearbeiter-ID', size=20, help='ID als Sachbearbeiter im PG9 (max. 20 Zeichen)') + @api.model def create(self, vals): vals['customer'] = False diff --git a/ext/custom-addons/dp_custom/models/sale.py b/ext/custom-addons/dp_custom/models/sale.py index 7f3cb19d..11cfe600 100644 --- a/ext/custom-addons/dp_custom/models/sale.py +++ b/ext/custom-addons/dp_custom/models/sale.py @@ -62,6 +62,7 @@ class SaleOrder(models.Model): weight_total = fields.Float(string='Gesamtgewicht', compute='_compute_weight_total') confirmation_nr = fields.Char('Freigabenummer') order_type = fields.Selection(ORDER_TYPES, string='Auftragsart', default='M') + clerk_id = fields.Many2one('res.users', string='Sachbearbeiter', domain=[('clerk_name', '!=', '')]) # pg9_call = fields.Char(string='PG9-Auftrag', compute='_pg9_call', store=False) pg9_call_D = fields.Char(string='PG9-Auftrag_D', compute='_pg9_call', store=False) @@ -324,7 +325,9 @@ class SaleOrder(models.Model): 'price_unit': vals['price_unit'], 'product_uom_qty': vals['product_uom_qty'], 'lot_id': lot_id, - 'from_designbox': True, + 'discount': vals.get('discount', 0), + 'hide_discount': vals.get('hide_discount', False), + 'from_designbox': vals.get('from_designbox',True), })) return order_lines @@ -360,7 +363,7 @@ class SaleOrder(models.Model): def _get_specified_fields(self): return ['origin', 'client_order_ref', 'note', 'date_order', 'assembled', 'line_id', 'partner_id', 'fiscal_position_id', 'user_id', 'payment_term_id', 'partner_delivery_id', 'partner_invoice_id', - 'assembly_state', 'confirmation_nr', 'confirm_order', 'order_type', 'internal_notes'] + 'assembly_state', 'confirmation_nr', 'confirm_order', 'order_type', 'internal_notes', 'from_designbox', 'discount', 'hide_discount'] @api.multi def write(self, vals): @@ -529,6 +532,8 @@ class SaleOrderLine(models.Model): sequence = fields.Integer(string='Sequence', default=9999) item_notes = fields.Text(string='Notes', related='lot_id.notes', store=False) item_warn = fields.Boolean(string='Notes!!!', compute='_compute_item_warn', store=False) + price_change = fields.Boolean(string='R', help='Preis aus Artikelstamm auslesen',default=False, store=False, track_visibility='always') + read_price = fields.Boolean(string='R',default=False, store=False, help='Preis aus Artikelstamm auslesen', track_visibility='always') @api.multi def _compute_item_warn(self): @@ -552,6 +557,18 @@ class SaleOrderLine(models.Model): return result + @api.onchange('product_uom_qty','read_price') + def product_uom_change(self): + save_price_unit = self.price_unit + result = super(SaleOrderLine,self).product_uom_change() + if save_price_unit != self.price_unit: + self.price_change = True + if not self.read_price: + self.price_unit = save_price_unit + else: + self.price_change = False + self.read_price = False + @api.model def create(self, vals): if not vals.get('intrastat_id', False): 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 8a968f54..e59f3e1c 100644 --- a/ext/custom-addons/dp_custom/views/res_partner_views.xml +++ b/ext/custom-addons/dp_custom/views/res_partner_views.xml @@ -110,6 +110,7 @@ + diff --git a/ext/custom-addons/dp_custom/views/res_users_views.xml b/ext/custom-addons/dp_custom/views/res_users_views.xml new file mode 100644 index 00000000..91ddfc2c --- /dev/null +++ b/ext/custom-addons/dp_custom/views/res_users_views.xml @@ -0,0 +1,13 @@ + + + + res.users.form.clerk + res.users + + + + + + + + diff --git a/ext/custom-addons/dp_custom/views/sale_views.xml b/ext/custom-addons/dp_custom/views/sale_views.xml index b8ef38a2..9fdd3904 100644 --- a/ext/custom-addons/dp_custom/views/sale_views.xml +++ b/ext/custom-addons/dp_custom/views/sale_views.xml @@ -61,6 +61,10 @@ --> + + price_change == True + price_change == True + + + + + + + @@ -116,6 +131,7 @@ + @@ -216,6 +232,7 @@ +