wizard 'create equipments'
This commit is contained in:
parent
4d02d61639
commit
41ec228407
@ -58,6 +58,8 @@ class OpticalEquipment(Workflow, ModelSQL, ModelView):
|
|||||||
states={'readonly': True})
|
states={'readonly': True})
|
||||||
|
|
||||||
current_subscription = fields.Many2One('sale.subscription')
|
current_subscription = fields.Many2One('sale.subscription')
|
||||||
|
software_version = fields.Char("Software version", size=None)
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def __setup__(cls):
|
def __setup__(cls):
|
||||||
|
31
product.py
31
product.py
@ -49,15 +49,20 @@ class Template(metaclass=PoolMeta):
|
|||||||
|
|
||||||
equipment = fields.Boolean('It is equipment',
|
equipment = fields.Boolean('It is equipment',
|
||||||
states={'invisible': Eval('type', 'goods') != 'goods',
|
states={'invisible': Eval('type', 'goods') != 'goods',
|
||||||
},depends=['type'])
|
},depends=['type']
|
||||||
|
)
|
||||||
maintenance_activity = fields.Boolean('Maintenance Activity',
|
maintenance_activity = fields.Boolean('Maintenance Activity',
|
||||||
states={'invisible': Eval('type', 'service') != 'service',
|
states={'invisible': Eval('type', 'service') != 'service',
|
||||||
},depends=['type'])
|
'readonly': If(Eval('equipment',True), True)
|
||||||
|
| If(Eval('replacement',True), True)
|
||||||
|
},depends=['type']
|
||||||
|
)
|
||||||
replacement = fields.Boolean('Replacement',
|
replacement = fields.Boolean('Replacement',
|
||||||
states={'invisible': Eval('type', 'goods') != 'goods',
|
states={'invisible': Eval('type', 'goods') != 'goods',
|
||||||
},depends=['type'])
|
'readonly': If(Eval('equipment',True), True)
|
||||||
|
| If(Eval('maintenance_activity',True), True)
|
||||||
|
},depends=['type']
|
||||||
|
)
|
||||||
equipment_type = fields.Selection(_EQUIPMENT_TYPE, 'Equipment type',
|
equipment_type = fields.Selection(_EQUIPMENT_TYPE, 'Equipment type',
|
||||||
states={'required': Eval('equipment', False)},
|
states={'required': Eval('equipment', False)},
|
||||||
depends=['equipment']
|
depends=['equipment']
|
||||||
@ -89,10 +94,10 @@ class Template(metaclass=PoolMeta):
|
|||||||
states={'required': Eval('equipment', False)},
|
states={'required': Eval('equipment', False)},
|
||||||
depends=['equipment']
|
depends=['equipment']
|
||||||
)
|
)
|
||||||
reference = fields.Char("Reference", size=None)
|
reference_category = fields.Many2One('product.category', "Reference",
|
||||||
|
domain=[('parent', '=', Eval('model_category'))],
|
||||||
|
)
|
||||||
origin_country = fields.Many2One('country.country',"Origin Country")
|
origin_country = fields.Many2One('country.country',"Origin Country")
|
||||||
software_version = fields.Char(
|
|
||||||
"Software version", size=None)
|
|
||||||
refurbish = fields.Boolean('Refurbish')
|
refurbish = fields.Boolean('Refurbish')
|
||||||
|
|
||||||
#These are measurements required for the equipments, are in this place
|
#These are measurements required for the equipments, are in this place
|
||||||
@ -203,10 +208,16 @@ class Template(metaclass=PoolMeta):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
@fields.depends('mark_category', 'model_category')
|
@fields.depends('mark_category', 'model_category', 'reference_category')
|
||||||
def on_change_mark_category(self):
|
def on_change_mark_category(self):
|
||||||
if self.mark_category:
|
if not self.mark_category:
|
||||||
self.model_category = None
|
self.model_category = None
|
||||||
|
self.reference_category = None
|
||||||
|
|
||||||
|
@fields.depends('model_category', 'reference_category')
|
||||||
|
def on_change_model_category(self):
|
||||||
|
if not self.model_category:
|
||||||
|
self.reference_category = None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def view_attributes(cls):
|
def view_attributes(cls):
|
||||||
|
66
sale.py
66
sale.py
@ -51,60 +51,50 @@ class CreateSubscription(Wizard):
|
|||||||
])
|
])
|
||||||
create_subscription = StateAction('sale_subscription.act_subscription_form')
|
create_subscription = StateAction('sale_subscription.act_subscription_form')
|
||||||
|
|
||||||
def get_subscription_lines(self):
|
|
||||||
pool = Pool()
|
|
||||||
SubscriptionLine = pool.get('sale.subscription.line')
|
|
||||||
subscription_line = SubscriptionLine()
|
|
||||||
subscription_line.start_date = self.start_date
|
|
||||||
subscription_line.end_date = self.end_date
|
|
||||||
subscription_line.service = self.service
|
|
||||||
subcription_line.quantity = self.quantity
|
|
||||||
subcription_line.unit = self.service.product.unit
|
|
||||||
subscription_line.consumpiton_recurrence = self.service.consumption_recurrence
|
|
||||||
#raise UserError(str(dir(subscription_line)))
|
|
||||||
return [subscription_line]
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _subscription_start(self):
|
def _subscription_start(self):
|
||||||
sale = self.records[0]
|
|
||||||
#raise UserError(str(dir(self.records[0])))
|
|
||||||
subscription_lines = []
|
subscription_lines = []
|
||||||
#subscription.lines.append(get_subscription_lines())
|
return dict(start_date=self.start.start_date,
|
||||||
return dict(start_date = self.start.start_date,
|
end_date=self.start.end_date,
|
||||||
end_date = self.start.end_date,
|
invoice_recurrence=self.start.invoice_recurrence,
|
||||||
invoice_recurrence = self.start.invoice_recurrence,
|
invoice_start_date=self.start.invoice_start_date,
|
||||||
invoice_start_date = self.start.invoice_start_date,
|
service=self.start.service,
|
||||||
service = self.start.service,
|
quantity=self.start.quantity,
|
||||||
quantity = self.start.quantity,
|
unit_price=self.start.unit_price)
|
||||||
party=sale.party.id,
|
|
||||||
contact=sale.contact.id if sale.contact else None,
|
|
||||||
invoice_party=sale.invoice_party.id if sale.invoice_party else None,
|
|
||||||
invoice_address=sale.invoice_address.id,
|
|
||||||
payment_term=sale.payment_term.id if sale.payment_term else None,
|
|
||||||
)
|
|
||||||
|
|
||||||
def do_create_subscription(self, action):
|
def do_create_subscription(self, action):
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
Subscription = pool.get('sale.subscription')
|
Subscription = pool.get('sale.subscription')
|
||||||
#raise UserError(str(dir(self)))
|
SubscriptionLine = pool.get('sale.subscription.line')
|
||||||
|
|
||||||
|
sale = self.records[0]
|
||||||
a = self._subscription_start
|
a = self._subscription_start
|
||||||
#self.get_subscription_lines()
|
|
||||||
#raise UserError(str(dir(Subscription)))
|
subscription_lines = [SubscriptionLine(
|
||||||
|
start_date=a['start_date'],
|
||||||
|
end_date=a['end_date'],
|
||||||
|
consumption_recurrence=a['invoice_recurrence'],
|
||||||
|
service=a['service'],
|
||||||
|
unit=a['service'].product.default_uom,
|
||||||
|
quantity=a['quantity'],
|
||||||
|
unit_price=a['unit_price']
|
||||||
|
)]
|
||||||
|
|
||||||
subscription = Subscription(
|
subscription = Subscription(
|
||||||
start_date=a['start_date'],
|
start_date=a['start_date'],
|
||||||
end_date=a['end_date'],
|
end_date=a['end_date'],
|
||||||
invoice_recurrence=a['invoice_recurrence'],
|
invoice_recurrence=a['invoice_recurrence'],
|
||||||
invoice_start_date=a['invoice_start_date'],
|
invoice_start_date=a['invoice_start_date'],
|
||||||
party=a['party'],
|
party=sale.party.id,
|
||||||
contact=a['contact'],
|
contact=sale.contact.id if sale.contact else None,
|
||||||
invoice_party=a['contact'],
|
invoice_party=sale.invoice_party.id if sale.invoice_party else None,
|
||||||
invoice_address=a['invoice_address'],
|
invoice_address=sale.invoice_address.id,
|
||||||
payment_term=a['payment_term'],
|
payment_term=sale.payment_term.id if sale.payment_term else None,
|
||||||
|
lines=subscription_lines,
|
||||||
)
|
)
|
||||||
subscription.lines.append(get_subscription_lines())
|
|
||||||
subscription.save()
|
subscription.save()
|
||||||
|
|
||||||
#raise UserError(str(dir(subscription)))
|
|
||||||
|
|
||||||
|
|
||||||
class SaleLine(metaclass=PoolMeta):
|
class SaleLine(metaclass=PoolMeta):
|
||||||
|
@ -43,7 +43,6 @@
|
|||||||
<field name="origin_country"/>
|
<field name="origin_country"/>
|
||||||
<label name="current_subscription"/>
|
<label name="current_subscription"/>
|
||||||
<field name="current_subscription"/>
|
<field name="current_subscription"/>
|
||||||
|
|
||||||
<notebook>
|
<notebook>
|
||||||
<page string="Subscriptions" id="subscriptions_equipment">
|
<page string="Subscriptions" id="subscriptions_equipment">
|
||||||
<field name="subscription_history"/>
|
<field name="subscription_history"/>
|
||||||
|
@ -12,13 +12,13 @@ this repository contains the full copyright notices and license terms. -->
|
|||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="/form/notebook/page[@id='general']" position="after">
|
<xpath expr="/form/notebook/page[@id='general']" position="after">
|
||||||
<page string="Features" id="features">
|
<page string="Features" id="features">
|
||||||
<label name="reference"/>
|
|
||||||
<field name="reference"/>
|
|
||||||
<newline/>
|
<newline/>
|
||||||
<label name="mark_category"/>
|
<label name="mark_category"/>
|
||||||
<field name="mark_category"/>
|
<field name="mark_category"/>
|
||||||
<label name="model_category"/>
|
<label name="model_category"/>
|
||||||
<field name="model_category"/>
|
<field name="model_category"/>
|
||||||
|
<label name="reference_category"/>
|
||||||
|
<field name="reference_category"/>
|
||||||
<label name="equipment_type"/>
|
<label name="equipment_type"/>
|
||||||
<field name="equipment_type"/>
|
<field name="equipment_type"/>
|
||||||
<label name="calibration"/>
|
<label name="calibration"/>
|
||||||
@ -33,12 +33,11 @@ this repository contains the full copyright notices and license terms. -->
|
|||||||
<field name="origin_country"/>
|
<field name="origin_country"/>
|
||||||
<label name="main_tecnology"/>
|
<label name="main_tecnology"/>
|
||||||
<field name="main_tecnology"/>
|
<field name="main_tecnology"/>
|
||||||
<label name="software_version"/>
|
|
||||||
<field name="software_version"/>
|
|
||||||
<label name="useful_life"/>
|
<label name="useful_life"/>
|
||||||
<field name="useful_life"/>
|
<field name="useful_life"/>
|
||||||
<label name="warranty"/>
|
<label name="warranty"/>
|
||||||
<field name="warranty"/>
|
<field name="warranty"/>
|
||||||
|
<newline/>
|
||||||
<label name="observation"/>
|
<label name="observation"/>
|
||||||
<field name="observation"/>
|
<field name="observation"/>
|
||||||
</page>
|
</page>
|
||||||
|
Loading…
Reference in New Issue
Block a user