-
-
Notifications
You must be signed in to change notification settings - Fork 369
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[14.0][MIG] purchase_procurement_analytic
- Loading branch information
1 parent
e8d94d6
commit fdb6bec
Showing
10 changed files
with
56 additions
and
57 deletions.
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
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 |
---|---|---|
@@ -1,6 +1 @@ | ||
# Copyright 2016 Carlos Dauden <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import procurement | ||
from . import purchase_order_line | ||
from . import stock |
This file was deleted.
Oops, something went wrong.
57 changes: 48 additions & 9 deletions
57
purchase_procurement_analytic/models/purchase_order_line.py
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 |
---|---|---|
@@ -1,18 +1,57 @@ | ||
# Copyright 2018 ACSONE SA/NV | ||
# Copyright 2021 ACSONE SA/NV | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, models | ||
from odoo import fields, models | ||
from odoo.fields import first | ||
|
||
|
||
class PurchaseOrderLine(models.Model): | ||
|
||
_inherit = "purchase.order.line" | ||
|
||
@api.multi | ||
def _create_stock_moves(self, picking): | ||
moves = super(PurchaseOrderLine, self)._create_stock_moves(picking=picking) | ||
for move in moves.filtered(lambda m: not m.analytic_account_id): | ||
move.write( | ||
{"analytic_account_id": move.purchase_line_id.account_analytic_id.id} | ||
group_id = fields.Many2one("procurement.group") | ||
|
||
def _find_candidate( | ||
self, | ||
product_id, | ||
product_qty, | ||
product_uom, | ||
location_id, | ||
name, | ||
origin, | ||
company_id, | ||
values, | ||
): | ||
line = super()._find_candidate( | ||
product_id, | ||
product_qty, | ||
product_uom, | ||
location_id, | ||
name, | ||
origin, | ||
company_id, | ||
values, | ||
) | ||
analytic_id = values.get("analytic_account_id") | ||
if analytic_id: | ||
line_candidates = self.filtered( | ||
lambda line: line.account_analytic_id.id == analytic_id | ||
) | ||
if line_candidates: | ||
return first(line_candidates) | ||
return line | ||
|
||
def _prepare_purchase_order_line_from_procurement( | ||
self, product_id, product_qty, product_uom, company_id, values, po | ||
): | ||
res = super()._prepare_purchase_order_line_from_procurement( | ||
product_id, product_qty, product_uom, company_id, values, po | ||
) | ||
analytic_id = values.get("analytic_account_id") | ||
if analytic_id: | ||
res.update( | ||
{ | ||
"account_analytic_id": analytic_id, | ||
} | ||
) | ||
return moves | ||
return res |
This file was deleted.
Oops, something went wrong.
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 @@ | ||
* Denis Roussel <[email protected]> |
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,2 @@ | ||
This module allows to not group purchase lines that concern different | ||
analytic account if created from procurements. |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright 2016 Carlos Dauden <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import test_purchase_procurement_analytic | ||
# from . import test_purchase_procurement_analytic |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.