[MIG] stock_request_purchase: Migration to 13.0

This commit is contained in:
Joan Sisquella
2020-03-09 10:47:49 +01:00
parent 2c24aacc29
commit a8738fb918
14 changed files with 75 additions and 64 deletions

View File

@@ -0,0 +1 @@
../../../../stock_request_purchase

View File

@@ -0,0 +1,6 @@
import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

View File

@@ -1,13 +1,13 @@
# Copyright 2017 Eficent Business and IT Consulting Services, S.L.
# Copyright 2017-20 ForgeFlow S.L. (https://www.forgeflow.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
{
"name": "Stock Request Purchase",
"summary": "Internal request for stock",
"version": "12.0.1.1.2",
"version": "13.0.1.0.0",
"license": "LGPL-3",
"website": "https://github.com/stock-logistics-warehouse",
"author": "Eficent, " "Odoo Community Association (OCA)",
"author": "ForgeFlow, Odoo Community Association (OCA)",
"category": "Warehouse Management",
"depends": ["stock_request", "purchase_stock"],
"data": [

View File

@@ -1,4 +1,4 @@
# Copyright 2017 Eficent Business and IT Consulting Services, S.L.
# Copyright 2017-20 ForgeFlow S.L. (https://www.forgeflow.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import api, fields, models

View File

@@ -1,4 +1,4 @@
# Copyright 2017 Eficent Business and IT Consulting Services, S.L.
# Copyright 2017-20 ForgeFlow S.L. (https://www.forgeflow.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import _, api, fields, models
@@ -12,7 +12,6 @@ class PurchaseOrderLine(models.Model):
comodel_name="stock.request", string="Stock Requests", copy=False
)
@api.multi
def _prepare_stock_moves(self, picking):
res = super(PurchaseOrderLine, self)._prepare_stock_moves(picking)

View File

@@ -1,4 +1,4 @@
# Copyright 2017 Eficent Business and IT Consulting Services, S.L.
# Copyright 2017-20 ForgeFlow S.L. (https://www.forgeflow.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import _, api, fields, models
@@ -40,7 +40,6 @@ class StockRequest(models.Model):
)
)
@api.multi
def action_view_purchase(self):
action = self.env.ref("purchase.purchase_order_action_generic").read()[0]

View File

@@ -31,7 +31,6 @@ class StockRequestOrder(models.Model):
req.purchase_line_ids = req.stock_request_ids.mapped("purchase_line_ids")
req.purchase_count = len(req.purchase_ids)
@api.multi
def action_view_purchase(self):
action = self.env.ref("purchase.purchase_order_action_generic").read()[0]
purchases = self.mapped("purchase_ids")

View File

@@ -1,4 +1,4 @@
# Copyright 2017 Eficent Business and IT Consulting Services, S.L.
# Copyright 2017-20 ForgeFlow S.L. (https://www.forgeflow.com).
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import models
@@ -8,20 +8,20 @@ class StockRule(models.Model):
_inherit = "stock.rule"
def _prepare_purchase_order_line(
self, product_id, product_qty, product_uom, values, po, supplier
self, product_id, product_qty, product_uom, company_id, values, po
):
vals = super(StockRule, self)._prepare_purchase_order_line(
product_id, product_qty, product_uom, values, po, supplier
product_id, product_qty, product_uom, company_id, values, po
)
if "stock_request_id" in values:
vals["stock_request_ids"] = [(4, values["stock_request_id"])]
return vals
def _update_purchase_order_line(
self, product_id, product_qty, product_uom, values, line, partner
self, product_id, product_qty, product_uom, company_id, values, line
):
vals = super(StockRule, self)._update_purchase_order_line(
product_id, product_qty, product_uom, values, line, partner
product_id, product_qty, product_uom, company_id, values, line
)
if "stock_request_id" in values:
vals["stock_request_ids"] = [(4, values["stock_request_id"])]

View File

@@ -1,3 +1,3 @@
* Jordi Ballester <jordi.ballester@eficent.com>.
* Jordi Ballester <jordi.ballester@forgeflow.com>.
* Enric Tobella <etobella@creublanca.es>
* Kitti Upariphutthiphong <kittiu@ecosoft.co.th>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -1,4 +1,4 @@
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# Copyright 2016-20 ForgeFlow S.L. (https://www.forgeflow.com)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0).
from odoo import fields
@@ -39,9 +39,7 @@ class TestStockRequestPurchase(common.TransactionCase):
[self.main_company.id, self.company_2.id],
)
self.route_buy = self.warehouse.buy_pull_id.route_id
self.supplier = self.env["res.partner"].create(
{"name": "Supplier", "supplier": True}
)
self.supplier = self.env["res.partner"].create({"name": "Supplier"})
self.product = self._create_product("SH", "Shoes", False)
self.uom_dozen = self.env["uom.uom"].create(
@@ -63,7 +61,7 @@ class TestStockRequestPurchase(common.TransactionCase):
"name": name,
"password": "demo",
"login": name,
"email": "@".join([name, "@test.com"]),
"email": str(name) + "@test.com",
"groups_id": [(6, 0, group_ids)],
"company_ids": [(6, 0, company_ids)],
}
@@ -109,7 +107,9 @@ class TestStockRequestPurchase(common.TransactionCase):
}
order = (
self.env["stock.request.order"].sudo(self.stock_request_user).create(vals)
self.env["stock.request.order"]
.with_user(self.stock_request_user)
.create(vals)
)
order.action_confirm()
@@ -158,17 +158,19 @@ class TestStockRequestPurchase(common.TransactionCase):
"location_id": self.warehouse.lot_stock_id.id,
}
stock_request_1 = self.stock_request.sudo(self.stock_request_user).create(vals)
stock_request_2 = self.stock_request.sudo(self.stock_request_manager).create(
stock_request_1 = self.stock_request.with_user(self.stock_request_user).create(
vals
)
stock_request_2 = self.stock_request.with_user(
self.stock_request_manager
).create(vals)
stock_request_1.action_confirm()
self.assertEqual(
sum(stock_request_1.sudo().purchase_line_ids.mapped("product_qty")), 5
)
stock_request_2.action_confirm()
stock_request_2.with_user(self.stock_request_manager).sudo().action_confirm()
self.assertEqual(
sum(stock_request_2.sudo().purchase_line_ids.mapped("product_qty")), 10

View File

@@ -1,44 +1,52 @@
<?xml version="1.0"?>
<?xml version="1.0" ?>
<!-- Copyright 2016 Eficent Business and IT Consulting Services S.L.
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0) -->
<odoo>
<record id="purchase_order_form" model="ir.ui.view">
<field name="name">purchase.order.form</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_form"/>
<field name="groups_id" eval="[(4, ref('stock_request.group_stock_request_user'))]"/>
<field name="inherit_id" ref="purchase.purchase_order_form" />
<field
name="groups_id"
eval="[(4, ref('stock_request.group_stock_request_user'))]"
/>
<field name="arch" type="xml">
<xpath expr="//div[@name='button_box']" position="inside">
<button type="object"
name="action_view_stock_request"
class="oe_stat_button"
icon="fa-chain"
attrs="{'invisible':[('stock_request_ids', '=', [])]}">
<field name="stock_request_count" widget="statinfo"
string="Stock Requests"/>
<field name="stock_request_ids" invisible="1"/>
<button
type="object"
name="action_view_stock_request"
class="oe_stat_button"
icon="fa-chain"
attrs="{'invisible':[('stock_request_ids', '=', [])]}"
>
<field
name="stock_request_count"
widget="statinfo"
string="Stock Requests"
/>
<field name="stock_request_ids" invisible="1" />
</button>
</xpath>
<xpath expr="//field[@name='order_line']/form/sheet/notebook"
position="inside">
<xpath expr="//field[@name='order_line']/form//notebook" position="inside">
<page name="stock_requests" string="Stock Requests">
<field name="stock_request_ids"/>
<field name="stock_request_ids" />
</page>
</xpath>
</field>
</record>
<record id="purchase_order_line_form2" model="ir.ui.view">
<field name="name">purchase.order.line.form2</field>
<field name="model">purchase.order.line</field>
<field name="inherit_id" ref="purchase.purchase_order_line_form2"/>
<field name="groups_id" eval="[(4, ref('stock_request.group_stock_request_user'))]"/>
<field name="inherit_id" ref="purchase.purchase_order_line_form2" />
<field
name="groups_id"
eval="[(4, ref('stock_request.group_stock_request_user'))]"
/>
<field name="arch" type="xml">
<field name="name" position="after">
<separator string="Stock Requests"/>
<field name="stock_request_ids"/>
<separator string="Stock Requests" />
<field name="stock_request_ids" />
</field>
</field>
</record>
</odoo>

View File

@@ -1,27 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2017 Eficent
License LGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="stock_request_order_form" model="ir.ui.view">
<field name="name">stock.request.order.form</field>
<field name="model">stock.request.order</field>
<field name="inherit_id" ref="stock_request.stock_request_order_form"/>
<field name="groups_id" eval="[(4, ref('purchase.group_purchase_user'))]"/>
<field name="inherit_id" ref="stock_request.stock_request_order_form" />
<field name="groups_id" eval="[(4, ref('purchase.group_purchase_user'))]" />
<field name="arch" type="xml">
<div name="button_box" position="inside">
<field name="purchase_ids" invisible="1"/>
<button type="object"
<field name="purchase_ids" invisible="1" />
<button
type="object"
name="action_view_purchase"
class="oe_stat_button"
icon="fa-truck"
attrs="{'invisible': [('purchase_count', '=', 0)]}"
>
<field name="purchase_count" widget="statinfo"
string="Purchase"/>
>
<field name="purchase_count" widget="statinfo" string="Purchase" />
</button>
</div>
</field>
</record>
</odoo>

View File

@@ -1,26 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2017 Eficent
License LGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="view_stock_request_form" model="ir.ui.view">
<field name="name">stock.request.form</field>
<field name="model">stock.request</field>
<field name="inherit_id" ref="stock_request.view_stock_request_form"/>
<field name="groups_id" eval="[(4, ref('purchase.group_purchase_user'))]"/>
<field name="inherit_id" ref="stock_request.view_stock_request_form" />
<field name="groups_id" eval="[(4, ref('purchase.group_purchase_user'))]" />
<field name="arch" type="xml">
<div name="button_box" position="inside">
<field name="purchase_ids" invisible="1"/>
<button type="object"
<field name="purchase_ids" invisible="1" />
<button
type="object"
name="action_view_purchase"
class="oe_stat_button"
icon="fa-truck"
attrs="{'invisible': [('purchase_count', '=', 0)]}">
<field name="purchase_count" widget="statinfo"
string="Purchase"/>
attrs="{'invisible': [('purchase_count', '=', 0)]}"
>
<field name="purchase_count" widget="statinfo" string="Purchase" />
</button>
</div>
</field>
</record>
</odoo>