Skip to content
Snippets Groups Projects
Commit 5ebf1f5d authored by Tiffany Chang (tic)'s avatar Tiffany Chang (tic)
Browse files

[IMP] product_expiry: Add delivery slip expiration dates

This commit adds the option to have lot/serial number expiration
dates be included in a delivery report (via settings). This is only
applicable for stock.picking where 'State=Done', when 1 or more
lot/serial numbers are used, and 1 or more lot/serial number expiration
dates exist.

This completes subsection 4 of overall Improve delivery slip task.

Task: 2039720
parent d20467bb
Branches
Tags
No related merge requests found
......@@ -18,11 +18,14 @@ Following dates can be tracked:
Also implements the removal strategy First Expiry First Out (FEFO) widely used, for example, in food industries.
""",
'data': ['security/ir.model.access.csv',
'security/stock_security.xml',
'views/production_lot_views.xml',
'views/product_template_views.xml',
'views/res_config_settings_views.xml',
'views/stock_move_views.xml',
'views/stock_quant_views.xml',
'wizard/confirm_expiry_view.xml',
'report/report_deliveryslip.xml',
'report/report_lot_barcode.xml',
'data/product_expiry_data.xml'],
}
......@@ -3,6 +3,7 @@
from . import production_lot
from . import product_product
from . import res_config_settings
from . import stock_move_line
from . import stock_move
from . import stock_picking
......
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models
class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
group_expiry_date_on_delivery_slip = fields.Boolean("Display Expiration Dates on Delivery Slips",
implied_group='product_expiry.group_expiry_date_on_delivery_slip')
@api.onchange('group_lot_on_delivery_slip')
def _onchange_group_lot_on_delivery_slip(self):
if not self.group_lot_on_delivery_slip:
self.group_expiry_date_on_delivery_slip = False
@api.onchange('module_product_expiry')
def _onchange_module_product_expiry(self):
if not self.module_product_expiry:
self.group_expiry_date_on_delivery_slip = False
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="stock_report_delivery_document_inherit_product_expiry" inherit_id="stock.report_delivery_document">
<xpath expr="//t[@name='lot_serial']" position="after">
<t t-set="has_expiry_date" t-value="False"/>
<t t-set="has_expiry_date"
t-value="o.move_line_ids.filtered(lambda ml: ml.lot_id.expiration_date)"
groups="product_expiry.group_expiry_date_on_delivery_slip"/>
<t name="expiry_date" t-if="has_expiry_date">
<th>Expiration Date</th>
</t>
</xpath>
</template>
<template id="stock_report_delivery_has_serial_move_line_inherit_product_expiry" inherit_id="stock.stock_report_delivery_has_serial_move_line">
<xpath expr="//t[@name='move_line_lot']" position="after">
<t t-if="has_expiry_date">
<td><span t-field="move_line.lot_id.expiration_date" t-options='{"widget": "date"}'/></td>
</t>
</xpath>
</template>
</odoo>
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="0">
<record id="group_expiry_date_on_delivery_slip" model="res.groups">
<field name="name">Include expiration dates on delivery slip</field>
<field name="category_id" ref="base.module_category_hidden"/>
</record>
</data>
</odoo>
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="res_config_settings_view_form_stock" model="ir.ui.view">
<field name="name">res.config.settings.view.form.inherit.product.expiry.stock</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="stock.res_config_settings_view_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@id='group_lot_on_delivery_slip']" position="after">
<div class="col-12 col-lg-6 o_setting_box" attrs="{'invisible': ['|', ('group_lot_on_delivery_slip', '=', False), ('module_product_expiry', '=', False)]}" id="group_expiry_date_on_delivery_slip">
<div class="o_setting_left_pane">
<field name="group_expiry_date_on_delivery_slip"/>
</div>
<div class="o_setting_right_pane">
<label for="group_expiry_date_on_delivery_slip"/>
<div class="text-muted">
Expiration dates will appear on the delivery slip
</div>
</div>
</div>
</xpath>
</field>
</record>
</odoo>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment