-
-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[14.0][ADD] wms_connector #762
Closed
Closed
Changes from 1 commit
Commits
Show all changes
70 commits
Select commit
Hold shift + click to select a range
63bcbde
[ADD] wms_connector
kevinkhao d66c5de
wip
kevinkhao d85aeeb
wip
kevinkhao 64ba460
wip
kevinkhao 2408560
wip
kevinkhao 49fa6b8
wip
kevinkhao 3bbbb1c
wip
kevinkhao 69d5d4d
wip
kevinkhao bde235a
wip
kevinkhao 1295521
wip
kevinkhao 34542c9
wip
kevinkhao 8826d65
wip
kevinkhao 6f2c662
wip
kevinkhao 1741ca7
wip
kevinkhao 884dd7e
wip
kevinkhao 44494c6
wip
kevinkhao 48a4654
wip
kevinkhao a9f1087
wip
kevinkhao 123913e
wip
kevinkhao 2694d0f
wip
kevinkhao 71afb28
wip
kevinkhao 2b5e80a
change cron and filter logic
kevinkhao 0e04865
change export logic
kevinkhao e3745b8
cleanup
kevinkhao 6e6052f
misc fixes, tests
kevinkhao 9a97798
minor name fix
kevinkhao 2be02f1
minor interface fix
kevinkhao 2f85e81
wms_connector: improve export
sebastienbeau f196b4c
wms_connector: clean code, improve view
sebastienbeau 233b3f5
wms_connector: fix export, review product sync
sebastienbeau 8ba7bef
wms_connector: do not try to send record with error
sebastienbeau 048e83e
wms_connector: ADD make filetype consistent between task and queue
FranzPoize 05be645
wms_connector: ADD adds method_type and filepath to task mappings for…
FranzPoize 0d90371
FIX method_type and filepath default values
FranzPoize 179ea42
ADD storage backend value (mostly for test purpose right now)
FranzPoize 6923c08
wms_connector: improve code
sebastienbeau 0f2e0a9
wms_connector: ADD wms_connector_exported and is_wms_exportable fields
FranzPoize e1be055
wms_connector: ADD a smart button to the picking view form that links to
FranzPoize 1ea74a0
wms_connector: clean view, and simplify code, add cancel check
sebastienbeau 8756b21
Merge pull request #8 from akretion/14.0-wms_connector_3
sebastienbeau 8946312
wms_connector: ADD inventory import support
FranzPoize fc60d25
wms_connector: compute default_warehouse_id for inventory in a simple…
FranzPoize d18a784
wms_conne: return attachment queue
sebastienbeau dfe2fb5
wms_connector: fix getting task, show error message on picking, raise…
sebastienbeau 3c142fe
wms_connector: fix access right issue
sebastienbeau fdd62ed
wms_connector: fix cancelling sale order. Do not raise error if alrea…
sebastienbeau f8dc2e5
Merge remote-tracking branch 'origin/14.0-wms_connector_inventory_sup…
sebastienbeau 3e5b64d
wms_connector: improve UI, clean code
sebastienbeau b895a7f
wms_connector: fix computing warehouse_id
sebastienbeau d41fc57
wms_connector: purge binding that have been never exported, and clean…
sebastienbeau a8e2251
wms_connector: reset wms_export_date and file when force cancel, so w…
sebastienbeau 5c2cdee
wms_connector: do not unlink file sent
sebastienbeau 83f1f86
wms_connector: fix checking allowed to cancel
sebastienbeau f9239b7
wms_connector: do not edit picking already synchronized. Add fr trans…
sebastienbeau 83c7d9e
wms_connector: Allow sequence management by child specialization
FranzPoize 24b3096
wms_connector: encapsulate MAPPINGS and FILTER VAlS in function for i…
FranzPoize b338229
wms_connector_picking_batch: Adds picking batch specialization for wm…
FranzPoize 9da6bc7
wms_connector_picking_batch: Adds README.rst
FranzPoize d4ab4bc
wms_connector_picking_batch: good manifest
FranzPoize 3cc52c9
wms_connector_picking_batch: working filters
FranzPoize d6dcd70
wms_connector: allows to specify record_per_file to -1 which puts all…
FranzPoize 1b64cf4
wms_cconnector_picking_batch: fix wms_export_task_id access
FranzPoize 3a98018
wms_connector: makes filter_domains easier to modify by inheriting mo…
FranzPoize 863766f
wms_connector_picking_batch: modify filter_domains
FranzPoize a495733
wms_connector_picking_batch: fix stock_picking modal in stock_picking…
FranzPoize 842915d
wms_connector: adds missing field to stock_picking_views
FranzPoize c2f6b77
wms_connector_picking_batch: adds field to stock_picking_batch
FranzPoize 79d9f1a
wms_connector: remove incoming and outgoing constraints on exportable…
FranzPoize 39d0e7f
wms_connector_picking_batch: Choose batch transfer in state draft
FranzPoize f710273
[FIX] make it possible to export errored wms_product_sync without cha…
FranzPoize File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
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,23 @@ | ||
# Copyright 2023 Akretion | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Wms Connector", | ||
"summary": """ | ||
WMS Connector""", | ||
"version": "14.0.1.0.0", | ||
"license": "AGPL-3", | ||
"author": "Akretion,Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/wms", | ||
"depends": ["stock", "sale", "attachment_synchronize"], | ||
"data": [ | ||
"security/wms_product_sync.xml", | ||
"views/wms_product_sync.xml", | ||
"views/stock_picking.xml", | ||
"views/stock_warehouse.xml", | ||
"views/attachment_queue_view.xml", | ||
], | ||
"demo": [ | ||
"demo/storage_backend.xml", | ||
], | ||
} |
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 @@ | ||
from . import stock_picking_batch |
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,73 @@ | ||
from odoo import _, api, fields, models | ||
from odoo.exceptions import UserError | ||
|
||
|
||
class StockPikcingBatch(models.Model): | ||
_inherit = ["synchronize.exportable.mixin", "stock.picking.batch"] | ||
_name = "stock.picking.batch" | ||
|
||
is_wms_exportable = fields.Boolean( | ||
compute="_compute_is_wms_exportable", readonly=True, store=True | ||
) | ||
|
||
wms_sync_cancel_supported = fields.Boolean( | ||
compute="_compute_wms_sync_cancel_supported" | ||
) | ||
|
||
wms_import_attachment_id = fields.Many2one( | ||
"attachment.queue", index=True, readonly=True | ||
) | ||
wms_export_date = fields.Datetime(tracking=True) | ||
|
||
def _get_wms_export_task(self): | ||
return self.picking_type_id.warehouse_id.sudo().wms_task_id | ||
|
||
def _compute_wms_sync_cancel_supported(self): | ||
self.wms_sync_cancel_supported = False | ||
|
||
@api.depends( | ||
"picking_type_id.warehouse_id.active_wms_sync", | ||
"picking_type_id.code", | ||
) | ||
def _compute_is_wms_exportable(self): | ||
for rec in self: | ||
rec.is_wms_exportable = ( | ||
rec.picking_type_id.warehouse_id.active_wms_sync | ||
and rec.picking_type_id.code in ("incoming", "outgoing") | ||
) | ||
|
||
def _is_user_allowed_to_cancel(self): | ||
return self.env.user.has_group("stock.group_stock_manager") | ||
|
||
def action_force_cancel_wms(self): | ||
if not self._is_user_allowed_to_cancel(): | ||
raise UserError(_("You are not allowed to cancel this batch transfer")) | ||
self.wms_export_date = None | ||
self.wms_export_attachment_id = None | ||
return self.with_context(skip_wms_cancel_check=True).action_cancel() | ||
|
||
def action_cancel(self): | ||
for record in self.filtered(lambda p: p.state != "cancel"): | ||
if ( | ||
not self._context.get("skip_wms_cancel_check") | ||
and record.wms_export_date | ||
and not record.wms_sync_cancel_supported | ||
): | ||
raise UserError( | ||
_( | ||
"The batch transfer %s can not be deleted as it have been sent " | ||
"to the WMS, ask your manager to force the cancellation" | ||
) | ||
% record.name | ||
) | ||
return super().action_cancel() | ||
|
||
def _wms_check_if_editable(self): | ||
if self._context.get("skip_check_protected_fields"): | ||
return True | ||
for picking_batch in self: | ||
if picking_batch.wms_export_date: | ||
raise UserError( | ||
_("The batch transfer %s have been exported and can not be modified") | ||
% picking_batch.name | ||
) |
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,107 @@ | ||
from odoo import fields, models | ||
|
||
FILTER_VALS = { | ||
"wms_export_batch_picking_in_filter_id": { | ||
"name": "WMS: {} filter for picking batch in", | ||
"model_id": "stock.picking.batch", | ||
}, | ||
"wms_export_batch_picking_out_filter_id": { | ||
"name": "WMS: {} filter for picking batch out", | ||
"model_id": "stock.picking.batch", | ||
}, | ||
} | ||
FILTER_DOMAINS = { | ||
"wms_export_product_filter_id": "[]", | ||
"wms_export_picking_in_filter_id": '[("wms_export_date", "=", False),' | ||
' ("picking_type_id", "=", {}), ("state", "=", "assigned")]', | ||
"wms_export_picking_out_filter_id": '[("wms_export_date", "=", False),' | ||
' ("picking_type_id", "=", {}), ("state", "=", "assigned")]', | ||
} | ||
|
||
|
||
MAPPINGS = { | ||
"export_batch_pickings_in": { | ||
"fieldname_task": "wms_export_task_id", | ||
"fieldname_cron": "wms_export_batch_picking_in_cron_id", | ||
"filetype": "export", | ||
"method_type": "export", | ||
"filepath": "IN/", | ||
"name_fragment": "export batch pickings in", | ||
"code": "wh = env['stock.warehouse'].browse({})\n" | ||
"env['stock.picking.batch'].with_context(attachment_task=wh.{})._schedule_export(wh," | ||
"domain=wh._wms_domain_for('batch_pickings_in')),", | ||
}, | ||
"export_batch_pickings_out": { | ||
"fieldname_task": "wms_export_task_id", | ||
"fieldname_cron": "wms_export_batch_picking_out_cron_id", | ||
"filetype": "export", | ||
"method_type": "export", | ||
"filepath": "IN/", | ||
"name_fragment": "export batch pickings out", | ||
"code": "wh = env['stock.warehouse'].browse({})\n" | ||
"env['stock.picking.batch'].with_context(attachment_task=wh.{})._schedule_export(wh," | ||
"domain=wh._wms_domain_for('batch_pickings_out')),", | ||
}, | ||
} | ||
|
||
class StockWarehouse(models.Model): | ||
_inherit = "stock.warehouse" | ||
|
||
wms_export_batch_picking_in_cron_id = fields.Many2one("ir.cron", readonly=True) | ||
wms_export_batch_picking_out_cron_id = fields.Many2one("ir.cron", readonly=True) | ||
wms_export_batch_picking_in_filter_id = fields.Many2one("ir.filters") | ||
wms_export_batch_picking_out_filter_id = fields.Many2one("ir.filters") | ||
|
||
def _wms_domain_for(self, model_domain): | ||
domains = { | ||
"batch_pickings_in": self.wms_export_batch_picking_in_filter_id._get_eval_domain(), | ||
"batch_pickings_out": self.wms_export_batch_picking_out_filter_id._get_eval_domain(), | ||
} | ||
return domains[model_domain] | ||
|
||
def _get_mappings(self): | ||
mappings = super()._get_mappings() | ||
mappings.update(MAPPINGS) | ||
return mappings | ||
|
||
def _get_filter_vals(self): | ||
# TODO(franz) remove picking with batch id from the picking in and out filter | ||
filter_vals = super()._get_filter_vals() | ||
filter_vals.update(FILTER_VALS) | ||
return filter_vals | ||
|
||
def _activate_filters(self): | ||
self.wms_export_batch_picking_in_filter_id.domain = FILTER_DOMAINS[ | ||
"wms_export_batch_picking_in_filter_id" | ||
].format(self.in_type_id.id) | ||
self.wms_export_batch_picking_out_filter_id.domain = FILTER_DOMAINS[ | ||
"wms_export_batch_picking_out_filter_id" | ||
].format(self.out_type_id.id) | ||
|
||
def button_open_wms_batch_pickings_in(self): | ||
return { | ||
"name": "WMS synchronized transfers", | ||
"view_mode": "tree,form", | ||
"views": [ | ||
(False, "tree"), | ||
(False, "form"), | ||
], | ||
"res_model": "stock.picking.batch", | ||
"type": "ir.actions.act_window", | ||
"target": "current", | ||
"domain": self._wms_domain_for("batch_pickings_in"), | ||
} | ||
|
||
def button_open_wms_batch_pickings_out(self): | ||
return { | ||
"name": "WMS synchronized transfers", | ||
"view_mode": "tree,form", | ||
"views": [ | ||
(False, "tree"), | ||
(False, "form"), | ||
], | ||
"res_model": "stock.picking.batch", | ||
"type": "ir.actions.act_window", | ||
"target": "current", | ||
"domain": self._wms_domain_for("batch_pickings_out"), | ||
} |
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,93 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- Copyright 2023 Akretion | ||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> | ||
<odoo> | ||
|
||
<record model="ir.ui.view" id="stock_picking_form_view"> | ||
<field name="model">stock.picking</field> | ||
<field name="inherit_id" ref="stock.view_picking_form" /> | ||
<field name="arch" type="xml"> | ||
<header position="inside"> | ||
<field name="is_wms_exportable" invisible="True" /> | ||
<button | ||
name="button_trigger_export" | ||
type="object" | ||
string="Export to WMS" | ||
attrs="{'invisible': [ | ||
'|', | ||
'|', | ||
('wms_export_date', '!=', False), | ||
('is_wms_exportable', '=', False), | ||
('state', 'in', ('cancel', 'done', 'draft')), | ||
]}" | ||
/> | ||
<button | ||
name="action_force_cancel_wms" | ||
type="object" | ||
string="Force Cancel" | ||
groups="stock.group_stock_manager" | ||
attrs="{'invisible': [ | ||
'|', | ||
('wms_export_date', '=', False), | ||
('state', '=', 'cancel'), | ||
]}" | ||
confirm="Before cancelling, ensure that your have cancelled the picking in the | ||
external WMS" | ||
/> | ||
</header> | ||
<field name="date_done" position="before"> | ||
<field | ||
name="wms_export_date" | ||
attrs="{'invisible': [('is_wms_exportable', '=', False)]}" | ||
/> | ||
</field> | ||
<field name="group_id" position="after"> | ||
<field | ||
name="wms_export_attachment_id" | ||
attrs="{'invisible': [('wms_export_attachment_id', '=', False)]}" | ||
/> | ||
<field | ||
name="wms_import_attachment_id" | ||
attrs="{'invisible': [('wms_import_attachment_id', '=', False)]}" | ||
/> | ||
</field> | ||
<header position="after"> | ||
<div | ||
class="alert alert-danger" | ||
role="alert" | ||
attrs="{'invisible': [('wms_export_error', '=', False)]}" | ||
> | ||
<p>Synchronisation error</p> | ||
<field name="wms_export_error" /> | ||
</div> | ||
</header> | ||
</field> | ||
</record> | ||
|
||
<record model="ir.ui.view" id="stock_picking_search"> | ||
<field name="model">stock.picking</field> | ||
<field name="inherit_id" ref="stock.view_picking_internal_search" /> | ||
<field name="arch" type="xml"> | ||
<filter name="starred" position="after"> | ||
<separator /> | ||
<filter | ||
string="To export" | ||
name="not_wms_exported" | ||
domain="[('wms_export_date', '=', False)]" | ||
/> | ||
</filter> | ||
</field> | ||
</record> | ||
|
||
<record model="ir.ui.view" id="stock_picking_tree_view"> | ||
<field name="model">stock.picking</field> | ||
<field name="inherit_id" ref="stock.vpicktree" /> | ||
<field name="arch" type="xml"> | ||
<field name="date_deadline" position="after"> | ||
<field name="wms_export_date" string="Exported at" optional="True" /> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
|
||
</odoo> |
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,28 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- Copyright 2023 Akretion | ||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> | ||
<odoo> | ||
<record model="ir.ui.view" id="stock_warehouse_form_view"> | ||
<field name="name">stock.warehouse.form (in wms_connector)</field> | ||
<field name="model">stock.warehouse</field> | ||
<field name="inherit_id" ref="stock.view_warehouse" /> | ||
<field name="arch" type="xml"> | ||
<div class="oe_button_box" position="inside"> | ||
<button | ||
name="button_open_wms_batch_pickings_in" | ||
string="WMS sync batch transfer in" | ||
icon="fa-refresh" | ||
class="oe_stat_button" | ||
type="object" | ||
/> | ||
<button | ||
name="button_open_wms_pickings_out" | ||
string="WMS sync batch transfer pickings out" | ||
icon="fa-refresh" | ||
class="oe_stat_button" | ||
type="object" | ||
/> | ||
</div> | ||
</field> | ||
</record> | ||
</odoo> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor typo