mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[FIX] Various fixes:
- Error with the sequence number. - Visible texts that should be in uppercases. - order_id should only be visible if group_stock_request_order option is enabled. - adds more tests - adds consistency between models company-wise
This commit is contained in:
committed by
Jesús Alan Ramos Rodríguez
parent
c5b320146d
commit
f7fa6050d3
@@ -1,7 +1,8 @@
|
||||
# Copyright 2017 Eficent Business and IT Consulting Services, S.L.
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||
|
||||
from odoo import api, fields, models
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class PurchaseOrderLine(models.Model):
|
||||
@@ -21,3 +22,12 @@ class PurchaseOrderLine(models.Model):
|
||||
'requested_product_uom_qty': request.product_qty,
|
||||
}) for request in self.stock_request_ids]
|
||||
return res
|
||||
|
||||
@api.constrains('stock_request_ids')
|
||||
def _check_purchase_company_constrains(self):
|
||||
if any(any(req.company_id != pol.company_id for
|
||||
req in pol.stock_request_ids) for pol in self):
|
||||
raise ValidationError(
|
||||
_('You cannot link a purchase order line '
|
||||
'to a stock request that belongs to '
|
||||
'another company.'))
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
# Copyright 2017 Eficent Business and IT Consulting Services, S.L.
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||
|
||||
from odoo import api, fields, models
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class StockRequest(models.Model):
|
||||
@@ -23,6 +24,14 @@ class StockRequest(models.Model):
|
||||
request.purchase_ids = request.purchase_line_ids.mapped('order_id')
|
||||
request.purchase_count = len(request.purchase_ids)
|
||||
|
||||
@api.constrains('purchase_line_ids', 'company_id')
|
||||
def _check_purchase_company_constrains(self):
|
||||
if any(any(line.company_id != req.company_id for
|
||||
line in req.purchase_line_ids) for req in self):
|
||||
raise ValidationError(
|
||||
_('You have linked to a purchase order line '
|
||||
'that belongs to another company.'))
|
||||
|
||||
@api.multi
|
||||
def action_view_purchase(self):
|
||||
action = self.env.ref(
|
||||
|
||||
@@ -105,6 +105,8 @@ class TestStockRequestPurchase(common.TransactionCase):
|
||||
self.assertEqual(order.stock_request_ids.qty_in_progress, 0.0)
|
||||
|
||||
purchase = order.sudo().purchase_ids[0]
|
||||
self.assertEqual(purchase.company_id,
|
||||
order.stock_request_ids[0].company_id)
|
||||
purchase.button_confirm()
|
||||
picking = purchase.picking_ids[0]
|
||||
picking.action_confirm()
|
||||
|
||||
Reference in New Issue
Block a user