Skip to content

Commit

Permalink
[UPD] ssi_stock
Browse files Browse the repository at this point in the history
* QC HT/24/000640
  • Loading branch information
andhit-r committed Jul 3, 2024
1 parent 6df57f9 commit 332948d
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 23 deletions.
3 changes: 3 additions & 0 deletions ssi_stock/menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
<field name="groups_id" eval="[(6, 0, [ref('original_inventory_group')])]" />
</record>

<record id="stock.menu_action_production_lot_form" model="ir.ui.menu">
<field name="groups_id" eval="[(6, 0, [ref('original_inventory_group')])]" />
</record>


</odoo>
18 changes: 9 additions & 9 deletions ssi_stock/models/stock_production_lot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,32 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).


from odoo import fields, models, api
from odoo import api, fields, models


class StockProductionLot(models.Model):
_name = "stock.production.lot"
_inherit = ["stock.production.lot"]

@api.depends(
"stock_move_line_ids",
"stock_move_line_ids.date",
"stock_move_line_ids.move_id.state",
"tracking"
"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)
criteria = [("lot_id", "=", rec.id), ("state", "=", "done")]

first_move_line_id = self.env["stock.move.line"].search(
criteria, order="date, id", 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
)
tracking = fields.Selection(related="product_id.tracking", store=True)
stock_move_line_ids = fields.One2many(
comodel_name="stock.move.line",
inverse_name="lot_id",
Expand Down
18 changes: 18 additions & 0 deletions ssi_stock/security/res_group_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,24 @@
/>
</record>

<record id="serial_number_group" model="res.groups">
<field name="name">Serial Number</field>
<field name="category_id" ref="inventory_configurator_module_category" />
<field
name="users"
eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]"
/>
</record>

<record id="lot_group" model="res.groups">
<field name="name">Lot</field>
<field name="category_id" ref="inventory_configurator_module_category" />
<field
name="users"
eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]"
/>
</record>

<!-- Goods Receipt-->
<record id="goods_receipt_viewer_group" model="res.groups">
<field name="name">Viewer</field>
Expand Down
36 changes: 22 additions & 14 deletions ssi_stock/views/stock_production_lot_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
<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'" />
<field
name="serial_number_in_date"
invisible="context.get('tracking') != 'serial'"
/>
</xpath>
</data>
</field>
Expand All @@ -25,7 +28,10 @@
<data>
<xpath expr="//field[@name='product_id']" position="after">
<field name="tracking" invisible="1" />
<field name="serial_number_in_date" attrs="{'invisible': [('tracking', '!=', 'serial')]}" />
<field
name="serial_number_in_date"
attrs="{'invisible': [('tracking', '!=', 'serial')]}"
/>
</xpath>
</data>
</field>
Expand All @@ -42,12 +48,13 @@
</record>

<menuitem
id="serial_number_menu"
name="Serial Numbers"
parent="stock.menu_stock_inventory_control"
action="serial_number_action"
sequence="101"
/>
id="serial_number_menu"
name="Serial Numbers"
parent="stock.menu_stock_inventory_control"
action="serial_number_action"
groups="serial_number_group"
sequence="101"
/>

<record id="lot_action" model="ir.actions.act_window">
<field name="name">Lots</field>
Expand All @@ -60,11 +67,12 @@
</record>

<menuitem
id="lot_menu"
name="Lots"
parent="stock.menu_stock_inventory_control"
action="lot_action"
sequence="101"
/>
id="lot_menu"
name="Lots"
parent="stock.menu_stock_inventory_control"
action="lot_action"
sequence="101"
groups="lot_group"
/>

</odoo>

0 comments on commit 332948d

Please sign in to comment.