Add source

This commit is contained in:
Oscar Alvarez 2021-02-23 18:04:37 -05:00
parent 261dc6032a
commit eb9c79b755
6 changed files with 117 additions and 2 deletions

View File

@ -10,6 +10,7 @@ import stock
import invoice
import price_list
import product
import source
def register():
@ -29,12 +30,12 @@ def register():
invoice.InvoicesStart,
price_list.PriceListLine,
product.UpdatePriceProductStart,
source.SaleSource,
module='sale_shop', type_='model')
Pool.register(
sale.PrintSaleBySupplier,
sale.SaleShopDetailed,
invoice.Invoices,
product.UpdatePriceProduct,
module='sale_shop', type_='wizard')
Pool.register(
sale.SaleBySupplier,

52
source.py Normal file
View File

@ -0,0 +1,52 @@
# -*- coding: UTF-8 -*-
# This file is part electronic_mail_template module for Tryton.
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
from trytond.model import Workflow, ModelView, ModelSQL, fields
from trytond.pyson import Eval
from trytond.transaction import Transaction
__all__ = ['SaleSource']
STATES = {
'readonly': (Eval('state') != 'draft')
}
SOURCES = [
('', ''),
('mercadolibre', 'Mercado Libre'),
('rappi', 'Rappi'),
('melhous', 'Melhous'),
('ifood', 'IFood'),
('shopify', 'Shopify'),
('socialnetwork', 'Social Network'),
('direct', 'Direct'),
('webpage', 'Web Page'),
('internal', 'Internal'),
('platform', 'Platform'),
('telephone', 'Telephone'),
]
# Migration form web channel
# INSERT INTO sale_source (id, name, "type", active, company) SELECT id, name, channel_name, true, 1 FROM sale_web_channel;
class SaleSource(Workflow, ModelSQL, ModelView):
'Sale Source'
__name__ = 'sale.source'
_rec_name = 'name'
name = fields.Char('Name', required=True)
active = fields.Boolean('Active')
type = fields.Selection(SOURCES, 'Type', select=True, required=True)
company = fields.Many2One('company.company', 'Company', required=True)
party = fields.Many2One('party.party', 'Party')
payment_term = fields.Many2One('account.invoice.payment_term',
'Payment Term')
@staticmethod
def default_company():
return Transaction().context.get('company')
@staticmethod
def default_active():
return True

35
source.xml Normal file
View File

@ -0,0 +1,35 @@
<?xml version="1.0"?>
<!-- This file is part email_template module for Tryton.
The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. -->
<tryton>
<data>
<record model="ir.ui.view" id="sale_source_tree">
<field name="model">sale.source</field>
<field name="type">tree</field>
<field name="name">sale_source_tree</field>
</record>
<record model="ir.ui.view" id="sale_source_form">
<field name="model">sale.source</field>
<field name="type">form</field>
<field name="name">sale_source_form</field>
</record>
<record model="ir.action.act_window" id="act_sale_source">
<field name="name">Sale Sources</field>
<field name="res_model">sale.source</field>
</record>
<record model="ir.action.act_window.view" id="act_sale_source_view1">
<field name="sequence" eval="10"/>
<field name="view" ref="sale_source_tree"/>
<field name="act_window" ref="act_sale_source"/>
</record>
<record model="ir.action.act_window.view" id="act_sale_source_view2">
<field name="sequence" eval="20"/>
<field name="view" ref="sale_source_form"/>
<field name="act_window" ref="act_sale_source"/>
</record>
<menuitem action="act_sale_source" parent="sale.menu_configuration"
id="menu_source" sequence="90"/>
</data>
</tryton>

View File

@ -1,5 +1,5 @@
[tryton]
version=5.0.4
version=5.0.5
depends:
ir
company
@ -15,3 +15,4 @@ xml:
invoice.xml
price_list.xml
product.xml
source.xml

17
view/sale_source_form.xml Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0"?>
<!-- This file is part sale_shop module for Tryton.
The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. -->
<form>
<label name="name"/>
<field name="name"/>
<label name="active"/>
<field name="active"/>
<label name="type"/>
<field name="type"/>
<label name="company"/>
<field name="company" widget="selection"/>
<label name="party"/>
<field name="party"/>
<label name="payment_term"/>
<field name="payment_term" widget="selection"/>
</form>

View File

@ -0,0 +1,9 @@
<?xml version="1.0"?>
<!-- This file is part sale_shop module for Tryton.
The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. -->
<tree >
<field name="name"/>
<field name="type"/>
<field name="party"/>
<field name="active"/>
</tree>