-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b177391
commit 6df57f9
Showing
4 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Copyright 2024 OpenSynergy Indonesia | ||
# Copyright 2024 PT. Simetri Sinergi Indonesia | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
|
||
from odoo import fields, models, api | ||
|
||
|
||
class StockProductionLot(models.Model): | ||
_name = "stock.production.lot" | ||
_inherit = ["stock.production.lot"] | ||
|
||
@api.depends( | ||
"stock_move_line_ids.date", | ||
"stock_move_line_ids.move_id.state", | ||
"tracking" | ||
) | ||
def _compute_serial_number_in_date(self): | ||
for rec in self: | ||
serial_number_in_date = False | ||
if rec.tracking == "serial": | ||
first_move_line_id = self.env["stock.move.line"].search([ | ||
("id", "=", rec.stock_move_line_ids.ids), | ||
], order="date", limit=1) | ||
serial_number_in_date = first_move_line_id.date | ||
rec.serial_number_in_date = serial_number_in_date | ||
|
||
tracking = fields.Selection( | ||
related="product_id.tracking", | ||
store=True | ||
) | ||
stock_move_line_ids = fields.One2many( | ||
comodel_name="stock.move.line", | ||
inverse_name="lot_id", | ||
string="Stock Move Lines", | ||
copy=False, | ||
) | ||
serial_number_in_date = fields.Datetime( | ||
string="Incoming Date", | ||
compute="_compute_serial_number_in_date", | ||
compute_sudo=False, | ||
store=False, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- Copyright 2024 OpenSynergy Indonesia | ||
Copyright 2024 PT. Simetri Sinergi Indonesia | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> | ||
<odoo> | ||
|
||
<record id="view_production_lot_tree" model="ir.ui.view"> | ||
<field name="name">stock.production.lot - tree</field> | ||
<field name="model">stock.production.lot</field> | ||
<field name="inherit_id" ref="stock.view_production_lot_tree" /> | ||
<field name="arch" type="xml"> | ||
<data> | ||
<xpath expr="//field[@name='create_date']" position="before"> | ||
<field name="serial_number_in_date" invisible="context.get('tracking') != 'serial'" /> | ||
</xpath> | ||
</data> | ||
</field> | ||
</record> | ||
|
||
<record id="view_production_lot_form" model="ir.ui.view"> | ||
<field name="name">stock.production.lot - form</field> | ||
<field name="model">stock.production.lot</field> | ||
<field name="inherit_id" ref="stock.view_production_lot_form" /> | ||
<field name="arch" type="xml"> | ||
<data> | ||
<xpath expr="//field[@name='product_id']" position="after"> | ||
<field name="tracking" invisible="1" /> | ||
<field name="serial_number_in_date" attrs="{'invisible': [('tracking', '!=', 'serial')]}" /> | ||
</xpath> | ||
</data> | ||
</field> | ||
</record> | ||
|
||
<record id="serial_number_action" model="ir.actions.act_window"> | ||
<field name="name">Serial Numbers</field> | ||
<field name="type">ir.actions.act_window</field> | ||
<field name="res_model">stock.production.lot</field> | ||
<field name="view_mode">tree,form</field> | ||
<field name="domain">[('tracking', '=', 'serial')]</field> | ||
<field name="context">{'tracking': 'serial'}</field> | ||
<field name="view_mode">tree,form</field> | ||
</record> | ||
|
||
<menuitem | ||
id="serial_number_menu" | ||
name="Serial Numbers" | ||
parent="stock.menu_stock_inventory_control" | ||
action="serial_number_action" | ||
sequence="101" | ||
/> | ||
|
||
<record id="lot_action" model="ir.actions.act_window"> | ||
<field name="name">Lots</field> | ||
<field name="type">ir.actions.act_window</field> | ||
<field name="res_model">stock.production.lot</field> | ||
<field name="view_mode">tree,form</field> | ||
<field name="domain">[('tracking', '=', 'lot')]</field> | ||
<field name="context">{}</field> | ||
<field name="view_mode">tree,form</field> | ||
</record> | ||
|
||
<menuitem | ||
id="lot_menu" | ||
name="Lots" | ||
parent="stock.menu_stock_inventory_control" | ||
action="lot_action" | ||
sequence="101" | ||
/> | ||
|
||
</odoo> |