fix: se limpia la casa para migración a 6.8

This commit is contained in:
sinergia 2023-11-06 21:50:47 -05:00
parent a32b533391
commit f6cf2d1f9f
1 changed files with 77 additions and 76 deletions

153
shop.py
View File

@ -13,63 +13,64 @@ __all__ = ['PurchaseShop', 'PurchaseShopResUser', 'PurchaseShopParty']
_digits = (16, 2)
class PurchaseShop(ModelSQL, ModelView):
'Purchase Shop'
__name__ = 'purchase.shop'
name = fields.Char('Shop Name', required=True, select=True)
name = fields.Char('Shop Name', required=True, )
users = fields.Many2Many('purchase.shop-res.user', 'shop', 'user', 'Users')
address = fields.Many2One('party.address', 'Address', domain=[
('party', '=', Eval('company_party')),
], depends=['company_party'])
('party', '=', Eval('company_party')),
], depends=['company_party'])
warehouse = fields.Many2One('stock.location', "Warehouse", required=True,
domain=[('type', '=', 'warehouse')])
domain=[('type', '=', 'warehouse')])
currency = fields.Many2One('currency.currency', 'Currency',)
price_list = fields.Many2One('product.price_list', 'Price List')
payment_term = fields.Many2One('account.invoice.payment_term',
'Payment Term')
'Payment Term')
purchase_sequence = fields.Many2One(
'ir.sequence', 'Purchase Sequence', domain=[
('company', 'in', [Eval('company', -1), None]),
('sequence_type', '=', Id('purchase', 'sequence_type_purchase')),
],
],
depends=['company'])
purchase_invoice_method = fields.Selection([
(None, ''),
('manual', 'Manual'),
('order', 'On Order Processed'),
('shipment', 'On Shipment Sent')
], 'Purchase Invoice Method')
(None, ''),
('manual', 'Manual'),
('order', 'On Order Processed'),
('shipment', 'On Shipment Sent')
], 'Purchase Invoice Method')
purchase_shipment_method = fields.Selection([
(None, ''),
('manual', 'Manual'),
('order', 'On Order Processed'),
('invoice', 'On Invoice Paid'),
], 'Purchase Shipment Method')
(None, ''),
('manual', 'Manual'),
('order', 'On Order Processed'),
('invoice', 'On Invoice Paid'),
], 'Purchase Shipment Method')
company = fields.Many2One('company.company', 'Company', required=True,
domain=[
('id', If(Eval('context', {}).contains('company'), '=', '!='),
Eval('context', {}).get('company', 0)),
], select=True)
domain=[
('id', If(Eval('context', {}).contains('company'), '=', '!='),
Eval('context', {}).get('company', 0)),
], )
company_party = fields.Function(fields.Many2One('party.party',
'Company Party'),
'on_change_with_company_party')
active = fields.Boolean('Active', select=True)
analytic_root = fields.Many2One('analytic_account.account','Analytic Root', required=True,
domain=[
('type', '=', 'root'),
],
depends=['type']
)
'Company Party'),
'on_change_with_company_party')
active = fields.Boolean('Active', )
analytic_root = fields.Many2One('analytic_account.account', 'Analytic Root', required=True,
domain=[
('type', '=', 'root'),
],
depends=['type']
)
analytic_account = fields.Many2One('analytic_account.account',
'Analytic Account', required=True,
domain=[
('type', '=', 'normal')
],
depends=['analytic_root']
)
'Analytic Account', required=True,
domain=[
('type', '=', 'normal')
],
depends=['analytic_root']
)
partys = fields.Many2Many('purchase.shop_party', 'shop', 'party',
'Partys')
'Partys')
withholding_tax = fields.Many2One('account.tax', 'WithholdingTax',
domain=[
('rate', '<', 0),
@ -107,64 +108,64 @@ class PurchaseShop(ModelSQL, ModelView):
# SQLite doesn't support this query as it generates and update
# with an alias (AS) which is not valid on SQLite
query = shop_table.update(columns=[shop_table.currency],
values=[company_table.currency],
from_=[company_table],
where=((shop_table.company == company_table.id)
& (shop_table.currency == Null)))
values=[company_table.currency],
from_=[company_table],
where=((shop_table.company == company_table.id)
& (shop_table.currency == Null)))
cursor.execute(*query)
# Migration to remove Property
if not purchase_sequence_exist and property_exist:
cursor.execute(*property_
.join(field, condition=property_.field == field.id)
.join(model, condition=field.model == model.id)
.select(
property_.res,
property_.value,
where=property_.res.like(cls.__name__ + ',%')
& (field.name == 'purchase_sequence')
& (model.model == cls.__name__)))
.join(field, condition=property_.field == field.id)
.join(model, condition=field.model == model.id)
.select(
property_.res,
property_.value,
where=property_.res.like(cls.__name__ + ',%')
& (field.name == 'purchase_sequence')
& (model.model == cls.__name__)))
for res, value in cursor:
id_ = int(res.split(',')[1])
value = int(value.split(',')[1]) if value else None
update.execute(*table.update(
[table.purchase_sequence],
[value],
where=table.id == id_))
[table.purchase_sequence],
[value],
where=table.id == id_))
if not purchase_invoice_method_exist and property_exist:
cursor.execute(*property_
.join(field, condition=property_.field == field.id)
.join(model, condition=field.model == model.id)
.select(
property_.res,
property_.value,
where=property_.res.like(cls.__name__ + ',%')
& (field.name == 'purchase_invoice_method')
& (model.model == cls.__name__)))
.join(field, condition=property_.field == field.id)
.join(model, condition=field.model == model.id)
.select(
property_.res,
property_.value,
where=property_.res.like(cls.__name__ + ',%')
& (field.name == 'purchase_invoice_method')
& (model.model == cls.__name__)))
for res, value in cursor:
id_ = int(res.split(',')[1])
value = value.split(',')[1] if value else None
update.execute(*table.update(
[table.purchase_invoice_method],
[value],
where=table.id == id_))
[table.purchase_invoice_method],
[value],
where=table.id == id_))
if not purchase_shipment_method_exist and property_exist:
cursor.execute(*property_
.join(field, condition=property_.field == field.id)
.join(model, condition=field.model == model.id)
.select(
property_.res,
property_.value,
where=property_.res.like(cls.__name__ + ',%')
& (field.name == 'purchase_shipment_method')
& (model.model == cls.__name__)))
.join(field, condition=property_.field == field.id)
.join(model, condition=field.model == model.id)
.select(
property_.res,
property_.value,
where=property_.res.like(cls.__name__ + ',%')
& (field.name == 'purchase_shipment_method')
& (model.model == cls.__name__)))
for res, value in cursor:
id_ = int(res.split(',')[1])
value = value.split(',')[1] if value else None
update.execute(*table.update(
[table.purchase_shipment_method],
[value],
where=table.id == id_))
[table.purchase_shipment_method],
[value],
where=table.id == id_))
# Migration from 5.2: do not require price_list
table_h.not_null_action('price_list', action='remove')
@ -213,15 +214,15 @@ class PurchaseShopResUser(ModelSQL):
_table = 'purchase_shop_res_user'
shop = fields.Many2One('purchase.shop', 'Shop', ondelete='CASCADE',
select=True, required=True)
, required=True)
user = fields.Many2One('res.user', 'User', ondelete='RESTRICT',
required=True)
required=True)
class PurchaseShopParty(ModelSQL):
'Purchase Schop Party'
__name__ = 'purchase.shop_party'
shop = fields.Many2One('purchase.shop', 'Shop', ondelete='CASCADE',
select=True, required=True)
, required=True)
party = fields.Many2One('party.party', 'Party', ondelete='CASCADE',
required=True)