Task #034573: Split from product_brand to add more esale related fields

This commit is contained in:
Sim? Albert i Beltran 2018-06-13 16:24:34 +02:00
parent 8c1c3deeb7
commit a76654db39
13 changed files with 115 additions and 112 deletions

2
README
View File

@ -14,7 +14,7 @@ questions on the NaN·tic bug tracker, mailing list,
wiki or IRC channel: wiki or IRC channel:
* http://doc.tryton-erp.es/ * http://doc.tryton-erp.es/
* http://bitbucket.org/nantic/trytond-product_brand * http://bitbucket.org/nantic/trytond-product_brand_esale
* http://groups.tryton.org/ * http://groups.tryton.org/
* http://wiki.tryton.org/ * http://wiki.tryton.org/
* irc://irc.freenode.net/tryton * irc://irc.freenode.net/tryton

View File

@ -7,5 +7,4 @@ from . import product
def register(): def register():
Pool.register( Pool.register(
product.Brand, product.Brand,
product.Template, module='product_brand_esale', type_='model')
module='product_brand', type_='model')

View File

@ -1,7 +1,15 @@
# #
msgid "" msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n" msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:product.brand:"
msgid ""
"There is another brand with the same slug. The slug of the active brands "
"must be unique!"
msgstr ""
"Hi ha una altre marca amb el mateix slug. L'slug de les marques actives ha "
"de ser únic!"
msgctxt "field:product.brand,create_date:" msgctxt "field:product.brand,create_date:"
msgid "Create Date" msgid "Create Date"
msgstr "Data creació" msgstr "Data creació"
@ -10,10 +18,26 @@ msgctxt "field:product.brand,create_uid:"
msgid "Create User" msgid "Create User"
msgstr "Usuari creació" msgstr "Usuari creació"
msgctxt "field:product.brand,description:"
msgid "Brand Description"
msgstr "Descripció de la marca"
msgctxt "field:product.brand,id:" msgctxt "field:product.brand,id:"
msgid "ID" msgid "ID"
msgstr "ID" msgstr "ID"
msgctxt "field:product.brand,metadescription:"
msgid "Meta Description"
msgstr "Meta Description"
msgctxt "field:product.brand,metakeywords:"
msgid "Meta Keywords"
msgstr "Meta Keywords"
msgctxt "field:product.brand,metatitle:"
msgid "Meta Title"
msgstr "Meta Title"
msgctxt "field:product.brand,name:" msgctxt "field:product.brand,name:"
msgid "Name" msgid "Name"
msgstr "Nom" msgstr "Nom"
@ -22,6 +46,14 @@ msgctxt "field:product.brand,rec_name:"
msgid "Name" msgid "Name"
msgstr "Nom" msgstr "Nom"
msgctxt "field:product.brand,slug:"
msgid "Slug"
msgstr "Slug"
msgctxt "field:product.brand,url:"
msgid "URL"
msgstr "URL"
msgctxt "field:product.brand,write_date:" msgctxt "field:product.brand,write_date:"
msgid "Write Date" msgid "Write Date"
msgstr "Data modificació" msgstr "Data modificació"
@ -34,11 +66,19 @@ msgctxt "field:product.template,brand:"
msgid "Brand" msgid "Brand"
msgstr "Marca" msgstr "Marca"
msgctxt "model:ir.action,name:act_product_brand" msgctxt "help:product.brand,metadescription:"
msgid ""
"Almost all search engines recommend it to be shorter than 155 characters of "
"plain text"
msgstr ""
"La majoria de motors de cerca recomanen que sigui menor de 155 caracters de "
"text plà"
msgctxt "model:ir.action,name:"
msgid "Brands" msgid "Brands"
msgstr "Marques" msgstr "Marques"
msgctxt "model:ir.ui.menu,name:menu_product_brand" msgctxt "model:ir.ui.menu,name:"
msgid "Brands" msgid "Brands"
msgstr "Marques" msgstr "Marques"

View File

@ -1,7 +1,15 @@
# #
msgid "" msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n" msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:product.brand:"
msgid ""
"There is another brand with the same slug. The slug of the active brands "
"must be unique!"
msgstr ""
"Hay otra marca con el mismo slug. El slug de las marcas activas debe ser "
"único!"
msgctxt "field:product.brand,create_date:" msgctxt "field:product.brand,create_date:"
msgid "Create Date" msgid "Create Date"
msgstr "Fecha creación" msgstr "Fecha creación"
@ -14,6 +22,18 @@ msgctxt "field:product.brand,id:"
msgid "ID" msgid "ID"
msgstr "ID" msgstr "ID"
msgctxt "field:product.brand,metadescription:"
msgid "Meta Description"
msgstr "Meta Description"
msgctxt "field:product.brand,metakeywords:"
msgid "Meta Keywords"
msgstr "Meta Keywords"
msgctxt "field:product.brand,metatitle:"
msgid "Meta Title"
msgstr "Meta Title"
msgctxt "field:product.brand,name:" msgctxt "field:product.brand,name:"
msgid "Name" msgid "Name"
msgstr "Nombre" msgstr "Nombre"
@ -22,6 +42,14 @@ msgctxt "field:product.brand,rec_name:"
msgid "Name" msgid "Name"
msgstr "Nombre" msgstr "Nombre"
msgctxt "field:product.brand,slug:"
msgid "Slug"
msgstr "Slug"
msgctxt "field:product.brand,url:"
msgid "URL"
msgstr "URL"
msgctxt "field:product.brand,write_date:" msgctxt "field:product.brand,write_date:"
msgid "Write Date" msgid "Write Date"
msgstr "Fecha modificación" msgstr "Fecha modificación"
@ -34,11 +62,19 @@ msgctxt "field:product.template,brand:"
msgid "Brand" msgid "Brand"
msgstr "Marca" msgstr "Marca"
msgctxt "model:ir.action,name:act_product_brand" msgctxt "help:product.brand,metadescription:"
msgid ""
"Almost all search engines recommend it to be shorter than 155 characters of "
"plain text"
msgstr ""
"La mayoría de los motores de búsqueda recomiendan un texto plano de no más "
"de 155 caracteres."
msgctxt "model:ir.action,name:"
msgid "Brands" msgid "Brands"
msgstr "Marcas" msgstr "Marcas"
msgctxt "model:ir.ui.menu,name:menu_product_brand" msgctxt "model:ir.ui.menu,name:"
msgid "Brands" msgid "Brands"
msgstr "Marcas" msgstr "Marcas"

View File

@ -1,22 +1,23 @@
# The COPYRIGHT file at the top level of this repository contains the full # The COPYRIGHT file at the top level of this repository contains the full
# copyright notices and license terms. # copyright notices and license terms.
from trytond.model import ModelView, ModelSQL, fields, Unique from trytond.model import fields, Unique
from trytond.pool import PoolMeta from trytond.pool import PoolMeta
from trytond.modules.product.product import STATES, DEPENDS
from slug import slug from slug import slug
__all__ = ['Brand', 'Template'] __all__ = ['Brand']
class Brand(ModelSQL, ModelView): class Brand:
'''Brand''' __metaclass__ = PoolMeta
__name__ = 'product.brand' __name__ = 'product.brand'
name = fields.Char('Name', required=True, translate=True)
active = fields.Boolean('Active')
url = fields.Char('URL', translate=True) url = fields.Char('URL', translate=True)
slug = fields.Char('Slug', translate=True) slug = fields.Char('Slug', translate=True)
products = fields.One2Many('product.template', 'brand', 'Products') metadescription = fields.Char('Meta Description', translate=True,
help=('Almost all search engines recommend it to be shorter than 155 '
'characters of plain text'))
metakeywords = fields.Char('Meta Keywords', translate=True)
metatitle = fields.Char('Meta Title', translate=True)
@classmethod @classmethod
def __setup__(cls): def __setup__(cls):
@ -24,24 +25,13 @@ class Brand(ModelSQL, ModelView):
t = cls.__table__() t = cls.__table__()
cls._sql_constraints += [ cls._sql_constraints += [
('slug_uniq', Unique(t, t.active, t.slug), ('slug_uniq', Unique(t, t.active, t.slug),
'There is another brand with the same slug.\n' ('There is another brand with the same slug. The slug of the '
'The slug of the active brands must be unique!'), 'active brands must be unique!')),
] ]
@staticmethod
def default_active():
return True
@fields.depends('name', 'slug', 'active') @fields.depends('name', 'slug', 'active')
def on_change_with_slug(self): def on_change_with_slug(self):
if self.name and not self.slug and self.active: if self.name and not self.slug and self.active:
return slug(self.name) return slug(self.name)
else: else:
return self.slug return self.slug
class Template:
__name__ = 'product.template'
__metaclass__ = PoolMeta
brand = fields.Many2One('product.brand', 'Brand', states=STATES,
depends=DEPENDS)

View File

@ -3,58 +3,10 @@
copyright notices and license terms. --> copyright notices and license terms. -->
<tryton> <tryton>
<data> <data>
<!-- product.template -->
<record model="ir.ui.view" id="template_view_form">
<field name="model">product.template</field>
<field name="inherit" ref="product.template_view_form"/>
<field name="name">template_form</field>
</record>
<!-- product.brand -->
<record model="ir.ui.view" id="product_brand_view_form"> <record model="ir.ui.view" id="product_brand_view_form">
<field name="model">product.brand</field> <field name="model">product.brand</field>
<field name="type">form</field> <field name="inherit" ref="product_brand.product_brand_view_form"/>
<field name="name">product_brand_form</field> <field name="name">product_brand_form</field>
</record> </record>
<record model="ir.ui.view" id="product_brand_view_list">
<field name="model">product.brand</field>
<field name="type">tree</field>
<field name="name">product_brand_list</field>
</record>
<record model="ir.action.act_window" id="act_product_brand">
<field name="name">Brands</field>
<field name="res_model">product.brand</field>
</record>
<record model="ir.action.act_window.view" id="act_product_brand_view1">
<field name="sequence" eval="10"/>
<field name="view" ref="product_brand_view_list"/>
<field name="act_window" ref="act_product_brand"/>
</record>
<record model="ir.action.act_window.view" id="act_product_brand_view2">
<field name="sequence" eval="20"/>
<field name="view" ref="product_brand_view_form"/>
<field name="act_window" ref="act_product_brand"/>
</record>
<record model="ir.model.access" id="access_product_brand">
<field name="model" search="[('model', '=', 'product.brand')]"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="False"/>
<field name="perm_create" eval="False"/>
<field name="perm_delete" eval="False"/>
</record>
<record model="ir.model.access" id="access_product_brand_admin">
<field name="model" search="[('model', '=', 'product.brand')]"/>
<field name="group" ref="product.group_product_admin"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_delete" eval="True"/>
</record>
<menuitem action="act_product_brand" id="menu_product_brand"
parent="product.menu_configuration" sequence="50"/>
</data> </data>
</tryton> </tryton>

View File

@ -10,7 +10,7 @@ try:
except ImportError: except ImportError:
from ConfigParser import ConfigParser from ConfigParser import ConfigParser
MODULE = 'product_brand' MODULE = 'product_brand_esale'
PREFIX = 'nantic' PREFIX = 'nantic'
MODULE2PREFIX = {} MODULE2PREFIX = {}

View File

@ -1,8 +1,8 @@
# The COPYRIGHT file at the top level of this repository contains the full # The COPYRIGHT file at the top level of this repository contains the full
# copyright notices and license terms. # copyright notices and license terms.
try: try:
from trytond.modules.product_brand.tests.test_product_brand import suite from trytond.modules.product_brand_esale.tests.test_product_brand_esale import suite
except ImportError: except ImportError:
from .test_product_brand import suite from .test_product_brand_esale import suite
__all__ = ['suite'] __all__ = ['suite']

View File

@ -8,7 +8,7 @@ from trytond.tests.test_tryton import ModuleTestCase
class TestCase(ModuleTestCase): class TestCase(ModuleTestCase):
'Test module' 'Test module'
module = 'product_brand' module = 'product_brand_esale'
def suite(): def suite():

View File

@ -1,6 +1,6 @@
[tryton] [tryton]
version=4.9.0 version=4.9.0
depends: depends:
product product_brand
xml: xml:
product.xml product.xml

View File

@ -1,14 +1,17 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<!-- The COPYRIGHT file at the top level of this repository contains the full <!-- The COPYRIGHT file at the top level of this repository contains the full
copyright notices and license terms. --> copyright notices and license terms. -->
<form> <data>
<label name="name"/> <xpath expr="//field[@name='active']" position="after">
<field name="name"/> <label name="url"/>
<label name="active"/> <field name="url"/>
<field name="active"/> <label name="slug"/>
<label name="url"/> <field name="slug"/>
<field name="url"/> <label name="metatitle"/>
<label name="slug"/> <field name="metatitle"/>
<field name="slug"/> <label name="metakeywords"/>
<field name="products" colspan="4" widget="many2many"/> <field name="metakeywords"/>
</form> <label name="metadescription"/>
<field name="metadescription" colspan="3"/>
</xpath>
</data>

View File

@ -1,7 +0,0 @@
<?xml version="1.0"?>
<!-- The COPYRIGHT file at the top level of this repository contains the full
copyright notices and license terms. -->
<tree>
<field name="active"/>
<field name="name"/>
</tree>

View File

@ -1,10 +0,0 @@
<?xml version="1.0"?>
<!-- The COPYRIGHT file at the top level of this repository contains the full
copyright notices and license terms. -->
<data>
<xpath expr="/form/notebook/page[@id='general']/field[@name='cost_price_method']"
position="after">
<label name="brand"/>
<field name="brand"/>
</xpath>
</data>