Skip to content

Commit

Permalink
[UPD] ssi_stock
Browse files Browse the repository at this point in the history
  • Loading branch information
Miftahussalam authored and andhit-r committed Jul 3, 2024
1 parent b177391 commit 6df57f9
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 0 deletions.
1 change: 1 addition & 0 deletions ssi_stock/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"views/stock_quant_views.xml",
"views/stock_picking_views.xml",
"views/stock_warehouse_views.xml",
"views/stock_production_lot_views.xml",
"views/location_type_views.xml",
"views/product_category_views.xml",
"views/stock_location_views.xml",
Expand Down
1 change: 1 addition & 0 deletions ssi_stock/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
stock_rule,
stock_inventory,
stock_quant,
stock_production_lot,
mixin_picking_type_m2o_configurator,
mixin_picking_type_category_m2o_configurator,
)
43 changes: 43 additions & 0 deletions ssi_stock/models/stock_production_lot.py
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,
)
70 changes: 70 additions & 0 deletions ssi_stock/views/stock_production_lot_views.xml
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>

0 comments on commit 6df57f9

Please sign in to comment.