Add franchise category field in Set franchises wizard

This commit is contained in:
Guillem Barba 2016-04-07 10:36:51 +02:00
parent 8dbb9872a0
commit 48022bc1f0
4 changed files with 24 additions and 2 deletions

View File

@ -146,6 +146,10 @@ msgctxt "field:sale.franchise.price_list-sale.franchise,write_uid:"
msgid "Write User"
msgstr "Usuari modificació"
msgctxt "field:sale.franchise.price_list.set_franchises.start,category:"
msgid "Category"
msgstr "Categoria"
msgctxt "field:sale.franchise.price_list.set_franchises.start,franchises:"
msgid "Franchises"
msgstr "Franquícies"

View File

@ -146,6 +146,10 @@ msgctxt "field:sale.franchise.price_list-sale.franchise,write_uid:"
msgid "Write User"
msgstr "Usuario modificación"
msgctxt "field:sale.franchise.price_list.set_franchises.start,category:"
msgid "Category"
msgstr "Categoría"
msgctxt "field:sale.franchise.price_list.set_franchises.start,franchises:"
msgid "Franchises"
msgstr "Franquicias"

View File

@ -510,6 +510,7 @@ class SetFranchisesStart(ModelView):
price_list = fields.Many2One('sale.franchise.price_list', 'Price List',
readonly=True, required=True)
category = fields.Many2One('sale.franchise.category', 'Category')
franchises = fields.Many2Many('sale.franchise', None, None, 'Franchises')
@ -536,7 +537,16 @@ class SetFranchises(Wizard):
return defaults
def transition_process(self):
self.start.price_list.franchises = self.start.franchises
pool = Pool()
Franchise = pool.get('sale.franchise')
franchises = self.start.franchises
if self.start.category:
for franchise in Franchise.search([
('categories', 'in', [self.start.category.id]),
]):
if franchise not in franchises:
franchises.append(franchise)
self.start.price_list.franchises = franchises
self.start.price_list.save()
return 'end'

View File

@ -1,8 +1,12 @@
<?xml version="1.0"?>
<!-- The COPYRIGHT file at the top level of this repository contains the full
copyright notices and license terms. -->
<form string="Set Franchises" col="2">
<form string="Set Franchises">
<label name="price_list"/>
<field name="price_list"/>
<newline/>
<label name="category"/>
<field name="category"/>
<newline/>
<field name="franchises" colspan="4"/>
</form>