diff --git a/ext/custom-addons/dp_custom/models/__init__.py b/ext/custom-addons/dp_custom/models/__init__.py index 27b85503..bb776077 100644 --- a/ext/custom-addons/dp_custom/models/__init__.py +++ b/ext/custom-addons/dp_custom/models/__init__.py @@ -32,3 +32,4 @@ from . import ir_attachment from . import account from . import commission_account from . import res_users +from . import confirmation_queue diff --git a/ext/custom-addons/dp_custom/models/confirmation_queue.py b/ext/custom-addons/dp_custom/models/confirmation_queue.py new file mode 100644 index 00000000..289b248d --- /dev/null +++ b/ext/custom-addons/dp_custom/models/confirmation_queue.py @@ -0,0 +1,16 @@ +# Copyright 2019-Today Tischlerzentrum 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 ConfirmationQueue(models.Model): + _name = 'res.confirmation_queue' + _description = 'Queue for Order Confirmation No.' + _order = 'confirmation_nr' + + confirmation_nr = fields.Char(string="Freigabenummer", required=True) + origin = fields.Char(string="Referenzbeleg", required=True) + confirmation_date = fields.Datetime(string="Freigabe-Datum") + confirmation_processed = fields.Boolean(string="Freigabe-Verarbeitet", default=False) + diff --git a/ext/custom-addons/dp_custom/models/sale.py b/ext/custom-addons/dp_custom/models/sale.py index e452af21..6ae8eaa6 100644 --- a/ext/custom-addons/dp_custom/models/sale.py +++ b/ext/custom-addons/dp_custom/models/sale.py @@ -65,6 +65,7 @@ class SaleOrder(models.Model): 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', '!=', '')]) + desired_delivery_date = fields.Date(string='Wunschlieferdatum') # 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) @@ -210,6 +211,27 @@ class SaleOrder(models.Model): }) return order_list + @api.model + def pg_update_confirmation(self, vals): + """ + SST-3b + :param origin, confirmation_nr: + :return: + """ + origin = vals.get('origin', False) + if origin: + order_id = self.search([('origin', '=', origin)], order='id DESC',limit=1) + if order_id: + order_id.write(vals) + return {'id': order_id.id, 'name': order_id.name} + else: + cq = self.env['res.confirmation_queue'].search([('origin', '=', origin)]) + if cq: + cq.write(vals) + else: + cq.create(vals) + return {'id': -1} + @api.model def pg_update_quotation(self, vals): """ @@ -306,6 +328,14 @@ class SaleOrder(models.Model): if partner_invoice_id: if partner_invoice_id.property_account_position_id: fiscal_position_id = partner_invoice_id.property_account_position_id.id + dv = vals.get('desired_delivery_date',False) + if dv: + vals['desired_delivery_date'] = datetime.strptime(dv,'%d.%m.%Y').date() + + confirmed = self.env['res.confirmation_queue'].search([('origin', '=', vals['origin']),('confirmation_processed','=',False)]) + if confirmed: + vals['confirmation_nr'] = confirmed.confirmation_nr + confirmed.confirmation_processed = True vals.update({ 'partner_id': partner.id, 'partner_invoice_id': partner_invoice_id.id, @@ -463,6 +493,7 @@ class SaleOrder(models.Model): 'discount': vals.get('discount', 0), 'hide_discount': vals.get('hide_discount', False), 'from_designbox': vals.get('from_designbox',True), + 'customer_lead': vals.get('customer_lead', 0), })) return order_lines @@ -498,7 +529,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', 'from_designbox', 'discount', 'hide_discount'] + 'assembly_state', 'confirmation_nr', 'confirm_order', 'order_type', 'internal_notes', 'from_designbox', 'discount', 'hide_discount', 'desired_delivery_date'] @api.multi def write(self, vals): @@ -752,12 +783,37 @@ class SaleOrderLine(models.Model): break return allowed_write + # @api.model + # def correct_values(self, vals): + # if vals.get('product_id', False): + # product_id = self.env['product.product'].search([('default_code', '=', vals['product_id'])]) + # if product_id: + # vals['product_id'] = product_id.id + # delay = product_id.product_tmpl_id.sale_delay + # if vals.get('delivery_date',False): + # dlvd = datetime.strptime(vals.get('delivery_date'),'%d.%m.%Y').date() + # dlvdiff = (dlvd - datetime.now().date()).days + # if dlvdiff > 0 and dlvdiff > product_id.product_tmpl_id.sale_delay: + # delay = dlvdiff + # vals['customer_lead'] = delay + # else: + # raise ValidationError( + # _("Produkt \'%s\' kann nicht zugeordnet werden") % vals['product_id']) + # return vals + @api.model def correct_values(self, vals): if vals.get('product_id', False): product_id = self.env['product.product'].search([('default_code', '=', vals['product_id'])]) if product_id: vals['product_id'] = product_id.id + delay = product_id.product_tmpl_id.sale_delay + # if vals.get('delivery_date',False): + # dlvd = datetime.strptime(vals.get('delivery_date'),'%d.%m.%Y').date() + # dlvdiff = (dlvd - datetime.now().date()).days + # if dlvdiff > 0 and dlvdiff > product_id.product_tmpl_id.sale_delay: + # delay = dlvdiff + vals['customer_lead'] = delay else: raise ValidationError( _("Produkt \'%s\' kann nicht zugeordnet werden") % vals['product_id']) 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 d50de6a7..59a21b37 100644 --- a/ext/custom-addons/dp_custom/security/ir.model.access.csv +++ b/ext/custom-addons/dp_custom/security/ir.model.access.csv @@ -11,3 +11,4 @@ sale.access_sale_order_manager,sale.order.manager,model_sale_order,sales_team.gr 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 +access_res_confirmation_queue_user,access_res_confirmation_queue_user,model_res_confirmation_queue,base.group_user,1,1,1,1 diff --git a/ext/custom-addons/dp_custom/views/sale_views.xml b/ext/custom-addons/dp_custom/views/sale_views.xml index e7855c36..ffb195d3 100644 --- a/ext/custom-addons/dp_custom/views/sale_views.xml +++ b/ext/custom-addons/dp_custom/views/sale_views.xml @@ -20,6 +20,9 @@
+ + +