Skip to content

Commit

Permalink
[14.0][MIG] purchase_procurement_analytic
Browse files Browse the repository at this point in the history
  • Loading branch information
rousseldenis committed Nov 26, 2021
1 parent e8d94d6 commit fdb6bec
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 57 deletions.
8 changes: 4 additions & 4 deletions purchase_procurement_analytic/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
"name": "Purchase Procurement Analytic",
"summary": "This module sets analytic account in purchase order line from "
"procurement analytic account",
"version": "10.0.2.0.0",
"version": "14.0.1.0.0",
"category": "Analytic",
"license": "AGPL-3",
"author": "Tecnativa, " "Odoo Community Association (OCA)",
"maintainers": ["rousseldenis"],
"author": "ACSONE SA/NV, Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-analytic",
"depends": [
"purchase",
"procurement_analytic",
"purchase_stock",
"stock_analytic",
],
"installable": True,
Expand Down
5 changes: 0 additions & 5 deletions purchase_procurement_analytic/models/__init__.py
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
19 changes: 0 additions & 19 deletions purchase_procurement_analytic/models/procurement.py

This file was deleted.

57 changes: 48 additions & 9 deletions purchase_procurement_analytic/models/purchase_order_line.py
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
17 changes: 0 additions & 17 deletions purchase_procurement_analytic/models/stock.py

This file was deleted.

1 change: 1 addition & 0 deletions purchase_procurement_analytic/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Denis Roussel <[email protected]>
2 changes: 2 additions & 0 deletions purchase_procurement_analytic/readme/DESCRIPTION.rst
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.
2 changes: 1 addition & 1 deletion purchase_procurement_analytic/tests/__init__.py
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
1 change: 0 additions & 1 deletion setup/purchase_procurement_analytic/odoo/__init__.py

This file was deleted.

This file was deleted.

0 comments on commit fdb6bec

Please sign in to comment.