Remove sale cart dependency

This commit is contained in:
resteve 2016-02-23 17:59:35 +01:00
parent 01d381b6da
commit 4c70e829b5
4 changed files with 32 additions and 31 deletions

View File

@ -17,7 +17,7 @@ def register():
GalateaUser,
PaymentType,
Sale,
SaleCart,
SaleLine,
SaleShop,
Template,
Product,

32
sale.py
View File

@ -3,8 +3,9 @@
# the full copyright notices and license terms.
from trytond.pool import PoolMeta
from trytond.model import fields
from trytond.pyson import Eval, Not, Bool, And
__all__ = ['Sale']
__all__ = ['Sale', 'SaleLine']
__metaclass__ = PoolMeta
@ -12,3 +13,32 @@ class Sale:
__name__ = 'sale.sale'
galatea_user = fields.Many2One('galatea.user', 'Galatea User',
readonly=True)
class SaleLine:
__name__ = 'sale.line'
sid = fields.Char('Session')
galatea_user = fields.Many2One('galatea.user', 'Galatea User', readonly=True)
product_id = fields.Function(fields.Integer('Product ID'), 'get_product_id')
template_id = fields.Function(fields.Integer('Template ID'), 'get_template_id')
shop = fields.Many2One('sale.shop', 'Shop', domain=[
('id', 'in', Eval('context', {}).get('shops', [])),
])
@classmethod
def __setup__(cls):
super(SaleLine, cls).__setup__()
cls.party.states['required'] = And((Not(Bool(Eval('sid')))), cls.party.states['required'])
cls.party.depends.append('sid')
def get_product_id(self, name):
'''Return product ID'''
if self.product:
return self.product.id
return None
def get_template_id(self, name):
'''Return template ID'''
if self.product:
return self.product.template.id
return None

View File

@ -1,28 +0,0 @@
# This file is part of the galatea_esale module for Tryton.
# The COPYRIGHT file at the top level of this repository contains the full
# copyright notices and license terms.
from trytond.pool import PoolMeta
from trytond.model import fields
__all__ = ['SaleCart']
__metaclass__ = PoolMeta
class SaleCart:
__name__ = 'sale.cart'
sid = fields.Char('Session', readonly=True)
galatea_user = fields.Many2One('galatea.user', 'Galatea User', readonly=True)
product_id = fields.Function(fields.Integer('Product ID'), 'get_product_id')
template_id = fields.Function(fields.Integer('Template ID'), 'get_template_id')
def get_product_id(self, name):
'''Return product ID'''
if self.product:
return self.product.id
return None
def get_template_id(self, name):
'''Return template ID'''
if self.product:
return self.product.template.id
return None

View File

@ -5,7 +5,6 @@ depends:
galatea
esale
product_esale
sale_cart
extras_depend:
sale_pos
xml: