Skip to content

Commit

Permalink
[FIX] stock_pull_list: fix pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
solo4games committed Oct 3, 2023
1 parent b9c7220 commit eb86b2a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion stock_pull_list/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from . import stock_picking
from . import stock_picking
17 changes: 11 additions & 6 deletions stock_pull_list/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from odoo import models, fields
from odoo import _, fields, models
from odoo.exceptions import Warning


Expand All @@ -10,16 +10,21 @@ def action_create_pull_list(self):
source_location = self[0].location_id

Check warning on line 10 in stock_pull_list/models/stock_picking.py

View check run for this annotation

Codecov / codecov/patch

stock_pull_list/models/stock_picking.py#L10

Added line #L10 was not covered by tests
for record in self:
if source_location != record.location_id:
raise Warning('Choose transfers with same source location')
raise Warning(_("Choose transfers with same source location"))

Check warning on line 13 in stock_pull_list/models/stock_picking.py

View check run for this annotation

Codecov / codecov/patch

stock_pull_list/models/stock_picking.py#L13

Added line #L13 was not covered by tests
if not record.picking_type_id.allow_server_action:
raise Warning(f'Operation type of {record.name} transfer did not handle server action')
if record.state != 'waiting':
raise Warning(

Check warning on line 15 in stock_pull_list/models/stock_picking.py

View check run for this annotation

Codecov / codecov/patch

stock_pull_list/models/stock_picking.py#L15

Added line #L15 was not covered by tests
f"Operation type of {record.name} transfer did not handle server action"
)
if record.state != "waiting":
raise Warning(f'Transfer {record.name} must be in "Waiting" state')
pull_wizard = self.env['stock.pull.list.wizard'].create({'location_id': source_location.id})
pull_wizard = self.env["stock.pull.list.wizard"].create(

Check warning on line 20 in stock_pull_list/models/stock_picking.py

View check run for this annotation

Codecov / codecov/patch

stock_pull_list/models/stock_picking.py#L19-L20

Added lines #L19 - L20 were not covered by tests
{"location_id": source_location.id}
)
res = pull_wizard.action_prepare()
return res

Check warning on line 24 in stock_pull_list/models/stock_picking.py

View check run for this annotation

Codecov / codecov/patch

stock_pull_list/models/stock_picking.py#L23-L24

Added lines #L23 - L24 were not covered by tests


class StockPickingType(models.Model):
_inherit = "stock.picking.type"

allow_server_action = fields.Boolean(string="Allow pull list server action")
allow_server_action = fields.Boolean(string="Allow pull list server action")
13 changes: 8 additions & 5 deletions stock_pull_list/views/stock_picking_views.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<odoo>
<record model="ir.actions.server" id="generate_pull_list">
<field name="name">Generate Pull List</field>
<field name="model_id" ref="stock.model_stock_picking"/>
<field name="model_id" ref="stock.model_stock_picking" />
<field name="binding_model_id" ref="stock.model_stock_picking" />
<field name="state">code</field>
<field name="code">
Expand All @@ -12,11 +12,14 @@
<record id="view_picking_type_form" model="ir.ui.view">
<field name="name">view.picking.type.form</field>
<field name="model">stock.picking.type</field>
<field name="inherit_id" ref="stock.view_picking_type_form"/>
<field name="inherit_id" ref="stock.view_picking_type_form" />
<field name="arch" type="xml">
<xpath expr="//sheet//group[@name='stock_picking_type_lot']" position="inside">
<field name="allow_server_action"/>
<xpath
expr="//sheet//group[@name='stock_picking_type_lot']"
position="inside"
>
<field name="allow_server_action" />
</xpath>
</field>
</record>
</odoo>
</odoo>

0 comments on commit eb86b2a

Please sign in to comment.