[imp] sale_order_batch: remove validity date
This commit is contained in:
parent
7743649824
commit
410194e352
7 changed files with 7 additions and 52 deletions
|
|
@ -38,6 +38,7 @@ Changelog
|
||||||
:1.0.0: Add Multi Company ability
|
:1.0.0: Add Multi Company ability
|
||||||
:1.0.1: rename product creation methode
|
:1.0.1: rename product creation methode
|
||||||
:1.1.0: Make validity_date persistent, add batches to SO views
|
:1.1.0: Make validity_date persistent, add batches to SO views
|
||||||
|
:1.1.1: Remove validity date
|
||||||
|
|
||||||
Bug Tracker
|
Bug Tracker
|
||||||
===========
|
===========
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
"author": "BAKEUP",
|
"author": "BAKEUP",
|
||||||
"website": "https://www.bakeup.org",
|
"website": "https://www.bakeup.org",
|
||||||
"category": "Sale",
|
"category": "Sale",
|
||||||
"version": "16.0.1.1.0",
|
"version": "16.0.1.1.1",
|
||||||
"depends": ["sale", "product"],
|
"depends": ["sale", "product"],
|
||||||
"data": [
|
"data": [
|
||||||
"data/ir_sequence_data.xml",
|
"data/ir_sequence_data.xml",
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
from odoo import _, api, fields, models
|
from odoo import _, fields, models
|
||||||
from odoo.exceptions import UserError
|
from odoo.exceptions import UserError
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -42,20 +42,7 @@ class SaleOrder(models.Model):
|
||||||
raise UserError(_(f"Sale Order belongs to a Batch: {', '.join(invalid_orders)}"))
|
raise UserError(_(f"Sale Order belongs to a Batch: {', '.join(invalid_orders)}"))
|
||||||
return super().action_confirm()
|
return super().action_confirm()
|
||||||
|
|
||||||
@api.model_create_multi
|
|
||||||
def create(self, vals_list):
|
|
||||||
for vals in vals_list:
|
|
||||||
if vals.get("batch_id"):
|
|
||||||
vals["validity_date"] = (
|
|
||||||
self.env["sale.order.batch"].search([("id", "=", vals.get("batch_id"))]).validity_date
|
|
||||||
)
|
|
||||||
return super().create(vals_list)
|
|
||||||
|
|
||||||
def write(self, vals):
|
def write(self, vals):
|
||||||
if vals.get("batch_id"):
|
|
||||||
vals["validity_date"] = (
|
|
||||||
self.env["sale.order.batch"].search([("id", "=", vals.get("batch_id"))]).validity_date
|
|
||||||
)
|
|
||||||
res = super().write(vals)
|
res = super().write(vals)
|
||||||
if vals.get("batch_id"):
|
if vals.get("batch_id"):
|
||||||
self.order_line._update_batch_product()
|
self.order_line._update_batch_product()
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
from datetime import timedelta
|
|
||||||
|
|
||||||
from odoo import _, api, fields, models
|
from odoo import _, api, fields, models
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -46,16 +44,6 @@ class SaleOrderBatch(models.Model):
|
||||||
help="Creation date of order batch,\nConfirmation date of confirmed orders.",
|
help="Creation date of order batch,\nConfirmation date of confirmed orders.",
|
||||||
default=fields.Datetime.now,
|
default=fields.Datetime.now,
|
||||||
)
|
)
|
||||||
validity_date = fields.Date(
|
|
||||||
string="Expiration",
|
|
||||||
compute="_compute_validity_date",
|
|
||||||
inverse="_inverse_validity_date",
|
|
||||||
store=True,
|
|
||||||
readonly=False,
|
|
||||||
copy=False,
|
|
||||||
precompute=True,
|
|
||||||
states=READONLY_FIELD_STATES,
|
|
||||||
)
|
|
||||||
sale_order_ids = fields.One2many("sale.order", "batch_id")
|
sale_order_ids = fields.One2many("sale.order", "batch_id")
|
||||||
sale_order_count = fields.Integer(compute="_compute_sale_order_count")
|
sale_order_count = fields.Integer(compute="_compute_sale_order_count")
|
||||||
sale_order_line_ids = fields.Many2many("sale.order.line", compute="_compute_sale_order_line_ids", store=True)
|
sale_order_line_ids = fields.Many2many("sale.order.line", compute="_compute_sale_order_line_ids", store=True)
|
||||||
|
|
@ -66,28 +54,6 @@ class SaleOrderBatch(models.Model):
|
||||||
product_count = fields.Integer(compute="_compute_product_count")
|
product_count = fields.Integer(compute="_compute_product_count")
|
||||||
partner_credit_warning = fields.Text(compute="_compute_partner_credit_warning")
|
partner_credit_warning = fields.Text(compute="_compute_partner_credit_warning")
|
||||||
|
|
||||||
@api.depends("company_id")
|
|
||||||
def _compute_validity_date(self):
|
|
||||||
enabled_feature = bool(self.env["ir.config_parameter"].sudo().get_param("sale.use_quotation_validity_days"))
|
|
||||||
if not enabled_feature:
|
|
||||||
self.validity_date = False
|
|
||||||
return
|
|
||||||
today = fields.Date.context_today(self)
|
|
||||||
for batch in self:
|
|
||||||
days = batch.company_id.quotation_validity_days
|
|
||||||
if days > 0:
|
|
||||||
batch.validity_date = today + timedelta(days)
|
|
||||||
else:
|
|
||||||
batch.validity_date = False
|
|
||||||
|
|
||||||
def _inverse_validity_date(self):
|
|
||||||
"""
|
|
||||||
Set validity date on all Sale Orders
|
|
||||||
"""
|
|
||||||
for batch in self:
|
|
||||||
for order in batch.sale_order_ids:
|
|
||||||
order.validity_date = batch.validity_date
|
|
||||||
|
|
||||||
@api.depends("sale_order_ids.order_line")
|
@api.depends("sale_order_ids.order_line")
|
||||||
def _compute_sale_order_line_ids(self):
|
def _compute_sale_order_line_ids(self):
|
||||||
for batch in self:
|
for batch in self:
|
||||||
|
|
|
||||||
|
|
@ -2,3 +2,4 @@
|
||||||
:1.0.0: Add Multi Company ability
|
:1.0.0: Add Multi Company ability
|
||||||
:1.0.1: rename product creation methode
|
:1.0.1: rename product creation methode
|
||||||
:1.1.0: Make validity_date persistent, add batches to SO views
|
:1.1.0: Make validity_date persistent, add batches to SO views
|
||||||
|
:1.1.1: Remove validity date
|
||||||
|
|
|
||||||
|
|
@ -400,6 +400,8 @@ anymore as log as they are part of a batch. Only Sale Orders in state Qutotation
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="field"><th class="field-name">1.1.0:</th><td class="field-body">Make validity_date persistent, add batches to SO views</td>
|
<tr class="field"><th class="field-name">1.1.0:</th><td class="field-body">Make validity_date persistent, add batches to SO views</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr class="field"><th class="field-name">1.1.1:</th><td class="field-body">Remove validity date</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@
|
||||||
<tree>
|
<tree>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="date_order"/>
|
<field name="date_order"/>
|
||||||
<field name="validity_date" optional="hide"/>
|
|
||||||
<field name="company_id" groups="base.group_multi_company" optional="show" readonly="1"/>
|
<field name="company_id" groups="base.group_multi_company" optional="show" readonly="1"/>
|
||||||
<field name="company_id" groups="!base.group_multi_company" invisible="1"/>
|
<field name="company_id" groups="!base.group_multi_company" invisible="1"/>
|
||||||
<field name="sale_order_ids" widget="many2many_tags"/>
|
<field name="sale_order_ids" widget="many2many_tags"/>
|
||||||
|
|
@ -92,7 +91,6 @@
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<field name="date_order" attrs="{'readonly': [('state','=','closed')]}"/>
|
<field name="date_order" attrs="{'readonly': [('state','=','closed')]}"/>
|
||||||
<field name="validity_date" attrs="{'invisiable': [('state','=','closed')]}"/>
|
|
||||||
<field name="company_id" options="{'no_create': True}" groups="base.group_multi_company"/>
|
<field name="company_id" options="{'no_create': True}" groups="base.group_multi_company"/>
|
||||||
<field name="company_id" invisible="1" groups="!base.group_multi_company"/>
|
<field name="company_id" invisible="1" groups="!base.group_multi_company"/>
|
||||||
</group>
|
</group>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue