-
Notifications
You must be signed in to change notification settings - Fork 243
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]fieldservice_stock_account_analytic: migrated to v14
- Loading branch information
1 parent
eecfd8a
commit 63d9a69
Showing
6 changed files
with
95 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,19 @@ | ||
# Copyright (C) 2019 Open Source Integrators | ||
# Copyright (C) 2021 Open Source Integrators | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
'name': 'Field Service - Stock - Analytic Accounting', | ||
'summary': 'Track costs of delivered items with analytic accounting', | ||
'license': 'AGPL-3', | ||
'version': '12.0.1.1.0', | ||
'category': 'Field Service', | ||
'author': "Open Source Integrators, " | ||
"Odoo Community Association (OCA)", | ||
'website': 'https://github.com/OCA/field-service', | ||
'depends': [ | ||
'fieldservice_account_analytic', | ||
'fieldservice_stock_account', | ||
'stock_request_analytic', | ||
"name": "Field Service - Stock - Analytic Accounting", | ||
"summary": "Track costs of delivered items with analytic accounting", | ||
"license": "AGPL-3", | ||
"version": "14.0.1.0.0", | ||
"category": "Field Service", | ||
"author": "Open Source Integrators, " "Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/field-service", | ||
"depends": [ | ||
"fieldservice_account_analytic", | ||
"fieldservice_stock_account", | ||
"stock_request_analytic", | ||
], | ||
'development_status': 'Beta', | ||
'maintainers': ['max3903'], | ||
"development_status": "Beta", | ||
"maintainers": ["max3903"], | ||
} |
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,17 +1,17 @@ | ||
# Copyright (C) 2019 Open Source Integrators | ||
# Copyright (C) 2021 Open Source Integrators | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import models | ||
|
||
|
||
class FSMOrder(models.Model): | ||
_inherit = 'fsm.order' | ||
_inherit = "fsm.order" | ||
|
||
def _prepare_inv_line_for_stock_request(self, stock_request, | ||
invoice=False): | ||
vals = super()._prepare_inv_line_for_stock_request( | ||
stock_request, invoice) | ||
vals.update({ | ||
'analytic_account_id': self.location_id.analytic_account_id.id, | ||
}) | ||
def _prepare_inv_line_for_stock_request(self, stock_request, invoice=False): | ||
vals = super()._prepare_inv_line_for_stock_request(stock_request, invoice) | ||
vals.update( | ||
{ | ||
"analytic_account_id": self.location_id.analytic_account_id.id, | ||
} | ||
) | ||
return vals |
15 changes: 7 additions & 8 deletions
15
fieldservice_stock_account_analytic/models/stock_request.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,17 @@ | ||
# Copyright (C) 2019 Open Source Integrators | ||
# Copyright (C) 2021 Open Source Integrators | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, models | ||
|
||
|
||
class StockRequest(models.Model): | ||
_inherit = 'stock.request' | ||
_inherit = "stock.request" | ||
|
||
@api.model | ||
def create(self, vals): | ||
if 'fsm_order_id' in vals and vals.get('fsm_order_id'): | ||
fsm_order = self.env['fsm.order'].browse(vals.get('fsm_order_id')) | ||
vals.update({ | ||
'analytic_account_id': | ||
fsm_order.location_id.analytic_account_id.id | ||
}) | ||
if vals.get("fsm_order_id"): | ||
fsm_order = self.env["fsm.order"].browse(vals.get("fsm_order_id")) | ||
vals.update( | ||
{"analytic_account_id": fsm_order.location_id.analytic_account_id.id} | ||
) | ||
return super().create(vals) |
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 @@ | ||
# Copyright (C) 2022 - TODAY, Open Source Integrators | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) | ||
|
||
from . import test_fsm_stock_account_analytic |
60 changes: 60 additions & 0 deletions
60
fieldservice_stock_account_analytic/tests/test_fsm_stock_account_analytic.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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Copyright (C) 2022 - TODAY, Open Source Integrators | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) | ||
|
||
import datetime | ||
|
||
from odoo.tests.common import TransactionCase | ||
|
||
|
||
class FSMStockAccountAnalyticCase(TransactionCase): | ||
def setUp(self): | ||
super(FSMStockAccountAnalyticCase, self).setUp() | ||
self.fsm_order = self.env["fsm.order"] | ||
self.test_location = self.env.ref("fieldservice.test_location") | ||
self.inv_location = self.env.ref("stock.stock_location_customers") | ||
self.test_person = self.env.ref("fieldservice.test_person") | ||
self.test_partner = self.env.ref("fieldservice.test_partner") | ||
self.analytic_model = self.env["account.analytic.account"] | ||
self.analytic = self.analytic_model.create({"name": "Test"}) | ||
|
||
def test_fsm_order(self): | ||
self.test_person.partner_id.supplier_rank = 1 | ||
self.test_location.inventory_location_id = self.inv_location.id | ||
self.test_location.analytic_account_id = self.analytic.id | ||
fsm_order = self.fsm_order.create( | ||
{"location_id": self.test_location.id, "person_id": self.test_person.id} | ||
) | ||
|
||
self.env["stock.picking.type"].create( | ||
{ | ||
"name": "Stock Request wh", | ||
"sequence_id": self.env.ref("stock_request.seq_stock_request_order").id, | ||
"code": "stock_request_order", | ||
"sequence_code": "SRO", | ||
"warehouse_id": fsm_order.warehouse_id.id, | ||
} | ||
) | ||
self.product_1 = self.env["product.product"].create( | ||
{ | ||
"name": "Product 1", | ||
"type": "product", | ||
"categ_id": self.env.ref("product.product_category_all").id, | ||
} | ||
) | ||
SR_1 = self.env["stock.request"].create( | ||
{ | ||
"warehouse_id": fsm_order.warehouse_id.id, | ||
"location_id": fsm_order.inventory_location_id.id, | ||
"product_id": self.product_1.id, | ||
"product_uom_qty": 1, | ||
"product_uom_id": self.product_1.uom_id.id, | ||
"fsm_order_id": fsm_order.id, | ||
"direction": "outbound", | ||
"expected_date": datetime.datetime.now(), | ||
"picking_policy": "direct", | ||
} | ||
) | ||
fsm_order.stock_request_ids = [(6, 0, SR_1.ids)] | ||
fsm_order.action_request_submit() | ||
SR_1.action_confirm() | ||
fsm_order.account_create_invoice() |