new field 'desired_delivery_date' in sale.order
new table confirmation_queue for imos-order-confirmation-nr.develop
parent
aff7ea7b7a
commit
7665c80e8f
|
|
@ -32,3 +32,4 @@ from . import ir_attachment
|
|||
from . import account
|
||||
from . import commission_account
|
||||
from . import res_users
|
||||
from . import confirmation_queue
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
# Copyright 2019-Today Tischlerzentrum gmbh (<http://www.tzaustria.at>)
|
||||
# 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)
|
||||
|
||||
|
|
@ -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'])
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
|
@ -20,6 +20,9 @@
|
|||
<field name="partner_flash" string="Flash: " class="oe_highlight" attrs="{'invisible':[('partner_flash','=',False)]}"/>
|
||||
<div class="oe_clear"/>
|
||||
</field>
|
||||
<field name="delivery_date" position="before">
|
||||
<field name="desired_delivery_date" position="before" class="oe_highlight" attrs="{'readonly':True, 'invisible':[('desired_delivery_date','=',False)]}"/>
|
||||
</field>
|
||||
<field name="client_order_ref" position="replace"/>
|
||||
<field name="origin" position="replace"/>
|
||||
<field name="payment_term_id" position="after">
|
||||
|
|
|
|||
Loading…
Reference in New Issue