mirror of
https://gitlab.com/datalifeit/trytond-sale_shipping_date
synced 2023-12-14 06:52:56 +01:00
Migrate to 6.0
This commit is contained in:
parent
cedfaccae1
commit
8692821a7f
|
@ -6,6 +6,6 @@ msgctxt "field:sale.sale,planned_shipping_date:"
|
|||
msgid "Planned Shipping Date"
|
||||
msgstr "Fecha envío estimada"
|
||||
|
||||
msgctxt "field:sale.line,planned_shipping_date:"
|
||||
msgctxt "field:sale.line,manual_shipping_date:"
|
||||
msgid "Planned Shipping Date"
|
||||
msgstr "Fecha envío estimada"
|
||||
msgstr "Fecha envío estimada"
|
||||
|
|
34
sale.py
34
sale.py
|
@ -4,8 +4,6 @@ from trytond.model import fields
|
|||
from trytond.pool import PoolMeta, Pool
|
||||
from trytond.pyson import Eval
|
||||
|
||||
__all__ = ['Sale', 'SaleLine']
|
||||
|
||||
|
||||
class Sale(metaclass=PoolMeta):
|
||||
__name__ = 'sale.sale'
|
||||
|
@ -22,10 +20,19 @@ class Sale(metaclass=PoolMeta):
|
|||
line = SaleLine(line_id)
|
||||
|
||||
res = super()._group_shipment_key(moves, move)
|
||||
|
||||
return res + (('planned_shipping_date',
|
||||
line.planned_shipping_date_used),
|
||||
line.manual_shipping_date_used),
|
||||
)
|
||||
|
||||
def _get_shipment_sale(self, Shipment, key):
|
||||
keys = list(key)
|
||||
for k in keys:
|
||||
if 'planned_shipping_date' in k:
|
||||
keys.remove(k)
|
||||
key = tuple(keys)
|
||||
return super()._get_shipment_sale(Shipment, key=key)
|
||||
|
||||
@classmethod
|
||||
def set_sale_date(cls, sales):
|
||||
for sale in sales:
|
||||
|
@ -39,26 +46,35 @@ class Sale(metaclass=PoolMeta):
|
|||
class SaleLine(metaclass=PoolMeta):
|
||||
__name__ = 'sale.line'
|
||||
|
||||
planned_shipping_date = fields.Date('Planned Shipping Date',
|
||||
manual_shipping_date = fields.Date('Planned Shipping Date',
|
||||
states={
|
||||
'invisible': Eval('type') != 'line',
|
||||
'readonly': Eval('sale_state') != 'draft'
|
||||
},
|
||||
depends=['type', 'sale_state'])
|
||||
|
||||
@fields.depends('sale')
|
||||
def on_change_with_planned_shipping_date(self):
|
||||
@classmethod
|
||||
def __register__(cls, module_name):
|
||||
table_h = cls.__table_handler__(module_name)
|
||||
if table_h.column_exist('planned_shipping_date'):
|
||||
table_h.column_rename('planned_shipping_date',
|
||||
'manual_shipping_date')
|
||||
|
||||
super().__register__(module_name)
|
||||
|
||||
@fields.depends('sale', '_parent_sale.planned_shipping_date')
|
||||
def on_change_with_manual_shipping_date(self):
|
||||
if self.sale:
|
||||
return self.sale.planned_shipping_date
|
||||
|
||||
def get_move(self, shipment_type):
|
||||
move = super().get_move(shipment_type)
|
||||
if move and not self.moves:
|
||||
move.planned_date = self.planned_shipping_date_used
|
||||
move.planned_date = self.manual_shipping_date_used
|
||||
return move
|
||||
|
||||
@property
|
||||
def planned_shipping_date_used(self):
|
||||
return self.planned_shipping_date or \
|
||||
def manual_shipping_date_used(self):
|
||||
return self.manual_shipping_date or \
|
||||
self.sale.planned_shipping_date or \
|
||||
self.shipping_date
|
||||
|
|
|
@ -39,18 +39,6 @@ Create chart of accounts::
|
|||
>>> accounts = get_accounts(company)
|
||||
>>> revenue = accounts['revenue']
|
||||
>>> expense = accounts['expense']
|
||||
>>> cash = accounts['cash']
|
||||
|
||||
>>> Journal = Model.get('account.journal')
|
||||
>>> PaymentMethod = Model.get('account.invoice.payment.method')
|
||||
>>> cash_journal, = Journal.find([('type', '=', 'cash')])
|
||||
>>> cash_journal.save()
|
||||
>>> payment_method = PaymentMethod()
|
||||
>>> payment_method.name = 'Cash'
|
||||
>>> payment_method.journal = cash_journal
|
||||
>>> payment_method.credit_account = cash
|
||||
>>> payment_method.debit_account = cash
|
||||
>>> payment_method.save()
|
||||
|
||||
Create tax::
|
||||
|
||||
|
@ -88,7 +76,6 @@ Create product::
|
|||
>>> template.name = 'product'
|
||||
>>> template.default_uom = unit
|
||||
>>> template.type = 'goods'
|
||||
>>> template.purchasable = True
|
||||
>>> template.salable = True
|
||||
>>> template.list_price = Decimal('10')
|
||||
>>> template.account_category = account_category_tax
|
||||
|
@ -113,13 +100,13 @@ Sale 2 products::
|
|||
>>> sale.lines.append(sale_line)
|
||||
>>> sale_line.product = product
|
||||
>>> sale_line.quantity = 2.0
|
||||
>>> sale_line.planned_shipping_date == today
|
||||
>>> sale_line.manual_shipping_date == today
|
||||
True
|
||||
>>> sale_line = SaleLine()
|
||||
>>> sale.lines.append(sale_line)
|
||||
>>> sale_line.product = product
|
||||
>>> sale_line.quantity = 3.0
|
||||
>>> sale_line.planned_shipping_date = today + relativedelta(days=2)
|
||||
>>> sale_line.manual_shipping_date = today + relativedelta(days=2)
|
||||
>>> sale.click('quote')
|
||||
>>> sale.click('confirm')
|
||||
>>> sale.state
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath expr="/form/label[@name='type']" position="before">
|
||||
<label name="planned_shipping_date"/>
|
||||
<field name="planned_shipping_date"/>
|
||||
<label name="manual_shipping_date"/>
|
||||
<field name="manual_shipping_date"/>
|
||||
</xpath>
|
||||
</data>
|
Loading…
Reference in a new issue