mirror of
https://gitlab.com/datalifeit/trytond-stock_location_product_limit
synced 2023-12-14 04:23:00 +01:00
Migrate to 6.0
This commit is contained in:
parent
00339fbaba
commit
4988d40333
7 changed files with 59 additions and 53 deletions
|
@ -587,7 +587,7 @@
|
|||
<text:sequence-decl text:display-outline-level="0" text:name="Drawing"/>
|
||||
</text:sequence-decls>
|
||||
<text:p text:style-name="P25"><text:placeholder text:placeholder-type="text"><for each="shipment in records"></text:placeholder></text:p>
|
||||
<text:p text:style-name="P27"><text:placeholder text:placeholder-type="text"><set_lang(shipment.delivery_address.party.lang and shipment.delivery_address.party.lang.code or 'en_US')></text:placeholder><text:placeholder text:placeholder-type="text"><shipment.set_lang(shipment.delivery_address.party.lang and shipment.delivery_address.party.lang.code or 'en_US')></text:placeholder><text:placeholder text:placeholder-type="text"><shipment.delivery_address.party.full_name></text:placeholder></text:p>
|
||||
<text:p text:style-name="P27"><text:placeholder text:placeholder-type="text"><set_lang(shipment.delivery_address.party.lang and shipment.delivery_address.party.lang.code or 'en')></text:placeholder><text:placeholder text:placeholder-type="text"><shipment.set_lang(shipment.delivery_address.party.lang and shipment.delivery_address.party.lang.code or 'en')></text:placeholder><text:placeholder text:placeholder-type="text"><shipment.delivery_address.party.full_name></text:placeholder></text:p>
|
||||
<text:p text:style-name="P26"><text:placeholder text:placeholder-type="text"><for each="line in shipment.delivery_address.full_address.split('\n')"></text:placeholder></text:p>
|
||||
<text:p text:style-name="P26"><text:placeholder text:placeholder-type="text"><line></text:placeholder></text:p>
|
||||
<text:p text:style-name="P26"><text:placeholder text:placeholder-type="text"></for></text:placeholder></text:p>
|
||||
|
|
|
@ -810,7 +810,7 @@
|
|||
<text:sequence-decl text:display-outline-level="0" text:name="Text"/>
|
||||
<text:sequence-decl text:display-outline-level="0" text:name="Drawing"/>
|
||||
</text:sequence-decls>
|
||||
<text:p text:style-name="P28"><text:placeholder text:placeholder-type="text"><set_lang(company.party.lang and company.party.lang.code or 'en_US')></text:placeholder></text:p>
|
||||
<text:p text:style-name="P28"><text:placeholder text:placeholder-type="text"><set_lang(company.party.lang and company.party.lang.code or 'en')></text:placeholder></text:p>
|
||||
<text:p text:style-name="P25">Product limit note</text:p>
|
||||
<text:p text:style-name="P22"><text:placeholder text:placeholder-type="text"><product.rec_name></text:placeholder></text:p>
|
||||
<text:p text:style-name="P23"/>
|
||||
|
|
12
locale/es.po
12
locale/es.po
|
@ -2,17 +2,13 @@
|
|||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "error:stock.location.product_limit:"
|
||||
msgctxt "model:ir.message,text:msg_stock_location_product_limit_location_product_uniq"
|
||||
msgid "The pair location, product must be unique."
|
||||
msgstr "La pareja ubicación, producto debe ser única."
|
||||
|
||||
msgctxt "error:stock.shipment.out:"
|
||||
msgid "The limit of the product %s is exceeded."
|
||||
msgstr "El límite para el producto %s ha sido superado."
|
||||
|
||||
msgctxt "error:stock.shipment.internal:"
|
||||
msgid "The limit of the product %s is exceeded."
|
||||
msgstr "El límite para el producto %s ha sido superado."
|
||||
msgctxt "model:ir.message,text:msg_stock_shipment_out_product_limit_exceeded"
|
||||
msgid "The limit of the product %(product)s is exceeded."
|
||||
msgstr "El límite para el producto %(product)s ha sido superado."
|
||||
|
||||
msgctxt "field:stock.location,diff_quantity:"
|
||||
msgid "Diff. quantity"
|
||||
|
|
15
message.xml
Normal file
15
message.xml
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- The COPYRIGHT file at the top level of this repository contains the full
|
||||
copyright notices and license terms. -->
|
||||
<tryton>
|
||||
<data grouped="1">
|
||||
<!-- stock.location.product_limit -->
|
||||
<record model="ir.message" id="msg_stock_location_product_limit_location_product_uniq">
|
||||
<field name="text">The pair location, product must be unique.</field>
|
||||
</record>
|
||||
<!-- stock.shipment.out -->
|
||||
<record model="ir.message" id="msg_stock_shipment_out_product_limit_exceeded">
|
||||
<field name="text">The limit of the product %(product)s is exceeded.</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
|
@ -1,5 +1,6 @@
|
|||
# The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from datetime import date
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from trytond.model import Unique
|
||||
from trytond.report import Report
|
||||
|
@ -7,6 +8,8 @@ from trytond.transaction import Transaction
|
|||
from trytond.model import ModelSQL, ModelView, fields
|
||||
from trytond.pyson import Eval
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.i18n import gettext
|
||||
from trytond.exceptions import UserWarning
|
||||
from trytond.wizard import StateReport
|
||||
from trytond.wizard import Wizard, StateTransition, StateView, Button
|
||||
|
||||
|
@ -41,8 +44,8 @@ class ProductLimit(ModelSQL, ModelView):
|
|||
t = cls.__table__()
|
||||
cls._sql_constraints = [
|
||||
('location_product_uniq', Unique(t, t.location, t.product),
|
||||
'The pair location, product must be unique.')
|
||||
]
|
||||
'stock_location_product_limit.'
|
||||
'msg_stock_location_product_limit_location_product_uniq')]
|
||||
|
||||
@fields.depends('product')
|
||||
def on_change_product(self):
|
||||
|
@ -109,14 +112,6 @@ class ProductLimit(ModelSQL, ModelView):
|
|||
class ShipmentOut(metaclass=PoolMeta):
|
||||
__name__ = 'stock.shipment.out'
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(ShipmentOut, cls).__setup__()
|
||||
cls._error_messages.update({
|
||||
'product_limit_exceeded':
|
||||
'The limit of the product %s is exceeded.'
|
||||
})
|
||||
|
||||
def product_limits_by_location(self):
|
||||
ProductLimit = Pool().get('stock.location.product_limit')
|
||||
return ProductLimit.product_limits_by_location(
|
||||
|
@ -128,8 +123,10 @@ class ShipmentOut(metaclass=PoolMeta):
|
|||
# similar to 'assign_try'.
|
||||
super().wait(shipments)
|
||||
|
||||
ProductLimit = Pool().get('stock.location.product_limit')
|
||||
Uom = Pool().get('product.uom')
|
||||
pool = Pool()
|
||||
ProductLimit = pool.get('stock.location.product_limit')
|
||||
Uom = pool.get('product.uom')
|
||||
Warning = pool.get('res.user.warning')
|
||||
|
||||
cache = set()
|
||||
|
||||
|
@ -157,10 +154,13 @@ class ShipmentOut(metaclass=PoolMeta):
|
|||
)
|
||||
if forecast_qty > Uom.compute_qty(
|
||||
uom, limit, move.product.default_uom):
|
||||
cls.raise_user_warning(
|
||||
'product_limit_exceeded_%s_%s' % (
|
||||
shipment.id, move.product.id),
|
||||
'product_limit_exceeded', move.product.name)
|
||||
warning_name = 'product_limit_exceeded_%s_%s' % (
|
||||
shipment.id, move.product.id)
|
||||
if Warning.check(warning_name):
|
||||
raise UserWarning(warning_name, gettext(
|
||||
'stock_location_product_limit.'
|
||||
'msg_stock_shipment_out_product_limit_exceeded',
|
||||
product=move.product.name))
|
||||
cache.add((move.product, move.quantity))
|
||||
|
||||
|
||||
|
@ -176,14 +176,6 @@ class ShipmentOutReturn(metaclass=PoolMeta):
|
|||
class ShipmentInternal(metaclass=PoolMeta):
|
||||
__name__ = 'stock.shipment.internal'
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super().__setup__()
|
||||
cls._error_messages.update({
|
||||
'product_limit_exceeded':
|
||||
'The limit of the product %s is exceeded.'
|
||||
})
|
||||
|
||||
def product_limits_by_location(self):
|
||||
ProductLimit = Pool().get('stock.location.product_limit')
|
||||
if not self.party or not self.party.warehouse:
|
||||
|
@ -195,9 +187,10 @@ class ShipmentInternal(metaclass=PoolMeta):
|
|||
def wait(cls, shipments):
|
||||
super().wait(shipments)
|
||||
|
||||
ProductLimit = Pool().get('stock.location.product_limit')
|
||||
Uom = Pool().get('product.uom')
|
||||
|
||||
pool = Pool()
|
||||
ProductLimit = pool.get('stock.location.product_limit')
|
||||
Uom = pool.get('product.uom')
|
||||
Warning = pool.get('res.user.warning')
|
||||
cache = set()
|
||||
|
||||
for shipment in shipments:
|
||||
|
@ -226,10 +219,13 @@ class ShipmentInternal(metaclass=PoolMeta):
|
|||
)
|
||||
if forecast_qty > Uom.compute_qty(
|
||||
uom, limit, move.product.default_uom):
|
||||
cls.raise_user_warning(
|
||||
'product_limit_exceeded_%s_%s' % (
|
||||
shipment.id, move.product.id),
|
||||
'product_limit_exceeded', move.product.name)
|
||||
warning_name = 'product_limit_exceeded_%s_%s' % (
|
||||
shipment.id, move.product.id)
|
||||
if Warning.check(warning_name):
|
||||
raise UserWarning(warning_name, gettext(
|
||||
'stock_location_product_limit.'
|
||||
'msg_stock_shipment_out_product_limit_exceeded',
|
||||
product=move.product.name))
|
||||
cache.add((move.product, move.quantity))
|
||||
|
||||
|
||||
|
@ -265,8 +261,8 @@ class Location(metaclass=PoolMeta):
|
|||
|
||||
@classmethod
|
||||
def get_diff_quantity(cls, locations, name):
|
||||
return dict([(l.id, l.limit_quantity -
|
||||
(l.quantity or 0)) for l in locations])
|
||||
return dict([(l.id, l.limit_quantity
|
||||
- (l.quantity or 0)) for l in locations])
|
||||
|
||||
|
||||
class ProductLimitNote(Report):
|
||||
|
@ -280,9 +276,7 @@ class ProductLimitNote(Report):
|
|||
Company = pool.get('company.company')
|
||||
Location = pool.get('stock.location')
|
||||
ProductLimit = pool.get('stock.location.product_limit')
|
||||
|
||||
report_context = super(ProductLimitNote, cls).get_context(records,
|
||||
data)
|
||||
report_context = super().get_context(records, header, data)
|
||||
|
||||
report_context['company'] = Company(data['company'])
|
||||
report_context['product'] = Product(data['product'])
|
||||
|
@ -331,13 +325,13 @@ class ProductLimitNote(Report):
|
|||
cumulate_moves[k[0]] += v
|
||||
cumulate += v
|
||||
report_context['cumulate'] = sorted([(k, v) for k, v in
|
||||
cumulate_moves.items()], key=lambda x: x[0])
|
||||
cumulate_moves.items()], key=lambda x: x[0] or date.min)
|
||||
return report_context
|
||||
|
||||
@classmethod
|
||||
def _get_sorted_moves(cls, moves):
|
||||
new_moves = [(k, v) for k, v in moves.items()]
|
||||
new_moves = sorted(new_moves, key=lambda x: x[0][0])
|
||||
new_moves = sorted(new_moves, key=lambda x: x[0][0] or date.min)
|
||||
return new_moves
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -111,10 +111,10 @@ Add two shipment lines of same product::
|
|||
|
||||
Set the shipment state to waiting::
|
||||
|
||||
>>> shipment_out.click('wait') # doctest: +IGNORE_EXCEPTION_DETAIL
|
||||
>>> shipment_out.click('wait')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
UserWarning: ...
|
||||
trytond.exceptions.UserWarning: The limit of the product Product is exceeded. -
|
||||
>>> len(shipment_out.outgoing_moves)
|
||||
2
|
||||
>>> len(shipment_out.inventory_moves)
|
||||
|
@ -143,7 +143,7 @@ Testing the reports::
|
|||
>>> ext, _, _, name = delivery_note.execute([shipment_out], {})
|
||||
>>> ext
|
||||
'odt'
|
||||
>>> name
|
||||
>>> name.split('-')[0]
|
||||
'Delivery Note'
|
||||
>>> conf = Model.get('stock.configuration')(1)
|
||||
>>> conf.show_limit = False
|
||||
|
@ -179,10 +179,10 @@ Create Shipment Internal::
|
|||
>>> move.company = company
|
||||
>>> move.unit_price = Decimal('1')
|
||||
>>> move.currency = company.currency
|
||||
>>> shipment_internal.click('wait') # doctest: +IGNORE_EXCEPTION_DETAIL
|
||||
>>> shipment_internal.click('wait')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
UserWarning: ...
|
||||
trytond.exceptions.UserWarning: The limit of the product Product is exceeded. -
|
||||
>>> pl.quantity = 10
|
||||
>>> pl.save()
|
||||
>>> shipment_internal.click('wait')
|
|
@ -10,3 +10,4 @@ extras_depend:
|
|||
|
||||
xml:
|
||||
product_limit.xml
|
||||
message.xml
|
Loading…
Reference in a new issue