-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[4800][ADD] stock_lot_purchase_attribute (#95)
* [4800][ADD] stock_lot_purchase_attribute
- Loading branch information
1 parent
ba6e8cd
commit 8e7174d
Showing
20 changed files
with
828 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
setup/stock_lot_purchase_attribute/odoo/addons/stock_lot_purchase_attribute
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 @@ | ||
../../../../stock_lot_purchase_attribute |
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,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |
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,65 @@ | ||
============================ | ||
Stock Lot Purchase Attribute | ||
============================ | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:60ee640d83d17e58432964e04a3b0c21d3c33bd8e9e2a8bd5fe9a100522633f6 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-qrtl%2Faxls--custom-lightgray.png?logo=github | ||
:target: https://github.com/qrtl/axls-custom/tree/16.0/stock_lot_purchase_attribute | ||
:alt: qrtl/axls-custom | ||
|
||
|badge1| |badge2| |badge3| | ||
|
||
This module adds fields to stock.lot to keep some information from the | ||
related purchase order. Corresponding fields are also added to relevant | ||
transactions, such as stock.move.line and stock.quant. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Usage | ||
===== | ||
|
||
Activate the scheduled action before clicking 'RUN MANUALLY' and | ||
deactivate it after the process is finished. We need to activate it | ||
because calling \_trigger() for each batch of records only works with an | ||
active cron job. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/qrtl/axls-custom/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us to smash it by providing a detailed and welcomed | ||
`feedback <https://github.com/qrtl/axls-custom/issues/new?body=module:%20stock_lot_purchase_attribute%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
------- | ||
|
||
* Quartile | ||
|
||
Maintainers | ||
----------- | ||
|
||
This module is part of the `qrtl/axls-custom <https://github.com/qrtl/axls-custom/tree/16.0/stock_lot_purchase_attribute>`_ project on GitHub. | ||
|
||
You are welcome to contribute. |
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,18 @@ | ||
# Copyright 2024 Quartile (https://www.quartile.co) | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
{ | ||
"name": "Stock Lot Purchase Attribute", | ||
"version": "16.0.1.0.0", | ||
"author": "Quartile", | ||
"website": "https://www.quartile.co", | ||
"category": "Warehouse Management", | ||
"license": "AGPL-3", | ||
"depends": ["purchase_stock"], | ||
"data": [ | ||
"data/ir_cron.xml", | ||
"views/stock_lot_views.xml", | ||
"views/stock_move_line_views.xml", | ||
"views/stock_quant_views.xml", | ||
], | ||
"installable": True, | ||
} |
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,19 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
<!-- This cron is for the purpose of initial data update, therefore is expected to | ||
be disabled in normal circumstances. --> | ||
<record model="ir.cron" id="update_stock_lot_purchase_information"> | ||
<field name="name">Stock Lot: Update Purchase Order and Purchase Partner</field> | ||
<field name="model_id" ref="model_stock_move_line" /> | ||
<field name="state">code</field> | ||
<field | ||
name="code" | ||
>model._cron_update_stock_lot_purchase_information(1000)</field> | ||
<field name="user_id" ref="base.user_root" /> | ||
<field name="interval_number">1</field> | ||
<field name="interval_type">days</field> | ||
<field name="numbercall">-1</field> | ||
<field name="doall" eval="False" /> | ||
<field name="active" eval="False" /> | ||
</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,56 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * stock_lot_purchase_attribute | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 16.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-09-11 03:10+0000\n" | ||
"PO-Revision-Date: 2024-09-11 03:10+0000\n" | ||
"Last-Translator: \n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: stock_lot_purchase_attribute | ||
#: model:ir.model,name:stock_lot_purchase_attribute.model_stock_lot | ||
msgid "Lot/Serial" | ||
msgstr "ロット/シリアル" | ||
|
||
#. module: stock_lot_purchase_attribute | ||
#: model:ir.model,name:stock_lot_purchase_attribute.model_stock_move_line | ||
msgid "Product Moves (Stock Move Line)" | ||
msgstr "製品の移動(在庫移動ライン)" | ||
|
||
#. module: stock_lot_purchase_attribute | ||
#: model:ir.model.fields,field_description:stock_lot_purchase_attribute.field_stock_lot__purchase_id | ||
#: model:ir.model.fields,field_description:stock_lot_purchase_attribute.field_stock_move_line__purchase_id | ||
#: model:ir.model.fields,field_description:stock_lot_purchase_attribute.field_stock_quant__purchase_id | ||
msgid "Purchase Order" | ||
msgstr "購買オーダ" | ||
|
||
#. module: stock_lot_purchase_attribute | ||
#: model:ir.model,name:stock_lot_purchase_attribute.model_stock_quant | ||
msgid "Quants" | ||
msgstr "保管ロット" | ||
|
||
#. module: stock_lot_purchase_attribute | ||
#: model:ir.actions.server,name:stock_lot_purchase_attribute.update_stock_lot_purchase_information_ir_actions_server | ||
#: model:ir.cron,cron_name:stock_lot_purchase_attribute.update_stock_lot_purchase_information | ||
msgid "Stock Lot: Update Purchase Order and Purchase Partner" | ||
msgstr "ロット/シリアル: 購買オーダと仕入先を更新" | ||
|
||
#. module: stock_lot_purchase_attribute | ||
#: model:ir.model,name:stock_lot_purchase_attribute.model_stock_move | ||
msgid "Stock Move" | ||
msgstr "在庫移動" | ||
|
||
#. module: stock_lot_purchase_attribute | ||
#: model:ir.model.fields,field_description:stock_lot_purchase_attribute.field_stock_lot__purchase_partner_id | ||
#: model:ir.model.fields,field_description:stock_lot_purchase_attribute.field_stock_move_line__purchase_partner_id | ||
#: model:ir.model.fields,field_description:stock_lot_purchase_attribute.field_stock_quant__purchase_partner_id | ||
msgid "Vendor" | ||
msgstr "仕入先" |
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,4 @@ | ||
from . import stock_lot | ||
from . import stock_move_line | ||
from . import stock_move | ||
from . import stock_quant |
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,21 @@ | ||
# Copyright 2024 Quartile (https://www.quartile.co) | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class StockLot(models.Model): | ||
_inherit = "stock.lot" | ||
|
||
# We make these fields editable on purpose so that the user can change the price as | ||
# appropriate. | ||
purchase_id = fields.Many2one( | ||
"purchase.order", | ||
"Purchase Order", | ||
tracking=True, | ||
) | ||
purchase_partner_id = fields.Many2one( | ||
"res.partner", | ||
"Vendor", | ||
tracking=True, | ||
) |
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 2024 Quartile (https://www.quartile.co) | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import models | ||
|
||
|
||
class StockMove(models.Model): | ||
_inherit = "stock.move" | ||
|
||
def _action_done(self, cancel_backorder=False): | ||
moves = super()._action_done(cancel_backorder=cancel_backorder) | ||
receipt_moves = moves.filtered(lambda x: x.purchase_line_id) | ||
for line in receipt_moves.move_line_ids: | ||
if not line.lot_id: | ||
continue | ||
purchase_line = line.move_id.purchase_line_id | ||
line.lot_id.write( | ||
{ | ||
"purchase_id": purchase_line.order_id.id, | ||
"purchase_partner_id": purchase_line.partner_id.id, | ||
} | ||
) | ||
return moves |
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,33 @@ | ||
# Copyright 2024 Quartile (https://www.quartile.co) | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class StockMoveLine(models.Model): | ||
_inherit = "stock.move.line" | ||
|
||
purchase_id = fields.Many2one(related="lot_id.purchase_id", store=True) | ||
purchase_partner_id = fields.Many2one( | ||
related="lot_id.purchase_partner_id", store=True | ||
) | ||
|
||
@api.model | ||
def _cron_update_stock_lot_purchase_information(self, limit): | ||
move_lines = self.sudo().search( | ||
[ | ||
("move_id.purchase_line_id", "!=", False), | ||
("lot_id", "!=", False), | ||
("lot_id.purchase_id", "=", False), | ||
], | ||
limit=limit, | ||
) | ||
for line in move_lines: | ||
line.lot_id.purchase_id = line.move_id.purchase_line_id.order_id.id | ||
line.lot_id.purchase_partner_id = ( | ||
line.move_id.purchase_line_id.partner_id.id | ||
) | ||
if len(move_lines) == limit: | ||
self.env.ref( | ||
"stock_lot_purchase_attribute.update_stock_lot_purchase_information" | ||
)._trigger() |
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,13 @@ | ||
# Copyright 2024 Quartile (https://www.quartile.co) | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class StockQuant(models.Model): | ||
_inherit = "stock.quant" | ||
|
||
purchase_id = fields.Many2one(related="lot_id.purchase_id", store=True) | ||
purchase_partner_id = fields.Many2one( | ||
related="lot_id.purchase_partner_id", store=True | ||
) |
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,3 @@ | ||
This module adds fields to stock.lot to keep some information from the related purchase | ||
order. Corresponding fields are also added to relevant transactions, such as stock.move.line | ||
and stock.quant. |
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,4 @@ | ||
Activate the scheduled action before clicking 'RUN MANUALLY' and | ||
deactivate it after the process is finished. We need to activate it | ||
because calling _trigger() for each batch of records only works with an | ||
active cron job. |
Oops, something went wrong.