Clean code
This commit is contained in:
parent
849b503420
commit
ae32f781b3
|
@ -1,6 +1,5 @@
|
|||
# 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.
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from trytond.pool import Pool
|
||||
from . import shop
|
||||
from . import sale
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# The COPYRIGHT file at the top level of this repository contains the full
|
||||
# copyright notices and license terms.
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from trytond.model import fields
|
||||
from trytond.pool import PoolMeta
|
||||
|
||||
|
|
4
goal.py
4
goal.py
|
@ -1,6 +1,6 @@
|
|||
# This file is part of 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
|
||||
|
||||
|
||||
# class SaleGoalLine(metaclass=PoolMeta):
|
||||
# "Sale Goal Line"
|
||||
|
|
4
goal.xml
4
goal.xml
|
@ -4,7 +4,7 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<tryton>
|
||||
<data>
|
||||
|
||||
<record model="ir.ui.view" id="sale_indicator_view_form">
|
||||
<!-- <record model="ir.ui.view" id="sale_indicator_view_form">
|
||||
<field name="model">sale.indicator</field>
|
||||
<field name="inherit" ref="sale_goal.sale_indicator_view_form"/>
|
||||
<field name="name">sale_indicator_form</field>
|
||||
|
@ -13,7 +13,7 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="model">sale.indicator</field>
|
||||
<field name="inherit" ref="sale_goal.sale_indicator_view_tree"/>
|
||||
<field name="name">sale_indicator_tree</field>
|
||||
</record>
|
||||
</record> -->
|
||||
|
||||
<!-- <record model="ir.ui.view" id="sale_indicator_view_tree">
|
||||
<field name="model">sale.indicator</field>
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
# This file is part Invoice_shop module for Tryton.
|
||||
# The COPYRIGHT file at the top level of this repository contains the full
|
||||
# copyright notices and license terms.
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from trytond.model import fields
|
||||
from trytond.pool import PoolMeta
|
||||
from trytond.pyson import Eval
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
# This file is part Invoice_shop module for Tryton.
|
||||
# The COPYRIGHT file at the top level of this repository contains the full
|
||||
# copyright notices and license terms.
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from decimal import Decimal
|
||||
from trytond.pool import PoolMeta, Pool
|
||||
from trytond.report import Report
|
||||
from trytond.model import fields, ModelView
|
||||
from trytond.pyson import Eval
|
||||
from datetime import date
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.wizard import (
|
||||
|
@ -19,7 +17,7 @@ class PriceListLine(metaclass=PoolMeta):
|
|||
digits=(16, 2), depends=['formula']), 'get_price_computed')
|
||||
price_w_tax_computed = fields.Function(fields.Numeric('Price W Tax Computed',
|
||||
digits=(16, 2), depends=['formula']), 'get_price_w_tax_computed')
|
||||
|
||||
|
||||
profit = fields.Function(fields.Float('Profit',
|
||||
digits=(16, 2)), 'get_profit')
|
||||
|
||||
|
|
17
product.py
17
product.py
|
@ -1,10 +1,8 @@
|
|||
# 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.
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
import itertools
|
||||
from trytond.model import fields, ModelView
|
||||
from trytond.wizard import Wizard, StateView, StateTransition, Button
|
||||
from trytond.pyson import Eval
|
||||
from trytond.pool import PoolMeta, Pool
|
||||
from trytond.modules.product import price_digits
|
||||
from trytond.transaction import Transaction
|
||||
|
@ -31,7 +29,8 @@ class UpdatePriceProductStart(ModelView):
|
|||
class UpdatePriceProduct(Wizard):
|
||||
'Update Price Product'
|
||||
__name__ = 'product.update_product'
|
||||
start = StateView('product.update_product.start',
|
||||
start = StateView(
|
||||
'product.update_product.start',
|
||||
'sale_shop.update_product_start_view_form', [
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Update', 'update', 'tryton-ok', default=True),
|
||||
|
@ -53,13 +52,12 @@ class UpdatePriceProduct(Wizard):
|
|||
|
||||
class Template(metaclass=PoolMeta):
|
||||
__name__ = 'product.template'
|
||||
|
||||
sale_price_w_tax = fields.Numeric('Sale Price With Tax', digits=(16, 2),
|
||||
depends=['list_price', 'account_category'])
|
||||
profit = fields.Function(fields.Float('Profit',
|
||||
digits=(16, 2)), 'get_profit')
|
||||
|
||||
list_prices_line = fields.Function(fields.Many2Many('product.price_list.line', None, None, 'List Price'),
|
||||
list_prices_line = fields.Function(fields.Many2Many(
|
||||
'product.price_list.line', None, None, 'List Price'),
|
||||
'get_list_prices'
|
||||
)
|
||||
|
||||
|
@ -106,7 +104,6 @@ class Template(metaclass=PoolMeta):
|
|||
|
||||
def get_profit(self, name=None):
|
||||
if self.cost_price and self.list_price and self.cost_price != 0:
|
||||
# res = float((self.list_price / self.cost_price) - 1) * 100 Oscar
|
||||
res = float(1-(self.cost_price/self.list_price)) * 100 # villa
|
||||
return round(res, 2)
|
||||
|
||||
|
@ -120,4 +117,4 @@ class Template(metaclass=PoolMeta):
|
|||
)
|
||||
dict_cursor.execute(*query)
|
||||
result = dict_cursor.fetchall()
|
||||
return list(itertools.chain(*result))
|
||||
return list(itertools.chain(*result))
|
||||
|
|
46
sale.py
46
sale.py
|
@ -1,7 +1,5 @@
|
|||
# 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.
|
||||
from itertools import groupby
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
import logging
|
||||
from decimal import Decimal
|
||||
from datetime import date, timedelta
|
||||
|
@ -14,7 +12,7 @@ from sql.operators import In
|
|||
from trytond.model import fields, Unique, ModelView
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.pyson import Bool, Eval, Or, Not, If
|
||||
from trytond.pyson import Bool, Eval, Or, Not
|
||||
from trytond.report import Report
|
||||
from trytond.wizard import (
|
||||
Wizard, StateView, StateAction, StateReport, Button, StateTransition
|
||||
|
@ -252,7 +250,7 @@ class Sale(metaclass=PoolMeta):
|
|||
if not sale.shop in user.shops:
|
||||
raise SaleWriteError(gettext('sale_shop.msg_edit_sale_by_shop'))
|
||||
super(Sale, cls).write(*args)
|
||||
|
||||
|
||||
@classmethod
|
||||
def delete(cls, sales):
|
||||
for sale in sales:
|
||||
|
@ -718,7 +716,7 @@ class SaleShopDetailedReport(Report):
|
|||
InvoiceLine = pool.get('account.invoice.line')
|
||||
Company = pool.get('company.company')
|
||||
Category = pool.get('product.template-product.category')
|
||||
|
||||
|
||||
categories = Category.search([('category', 'in', data['categories'])])
|
||||
products_ids = [c.template.id for c in categories]
|
||||
|
||||
|
@ -1189,7 +1187,7 @@ class WizardSalePayment(Wizard):
|
|||
('state', '=', 'draft')
|
||||
]
|
||||
context = Transaction().context
|
||||
|
||||
|
||||
if context.get('sale_device', None) and sale.sale_device:
|
||||
dom_statement.append(('sale_device', '=', sale.sale_device.id))
|
||||
|
||||
|
@ -1271,11 +1269,11 @@ class MultiplePaymentSaleStart(ModelView):
|
|||
@staticmethod
|
||||
def default_id():
|
||||
return 1
|
||||
|
||||
|
||||
@staticmethod
|
||||
def default_company():
|
||||
return Transaction().context.get('company')
|
||||
|
||||
|
||||
@staticmethod
|
||||
def default_amount():
|
||||
return Decimal(0)
|
||||
|
@ -1283,7 +1281,7 @@ class MultiplePaymentSaleStart(ModelView):
|
|||
@staticmethod
|
||||
def default_balance():
|
||||
return Decimal(0)
|
||||
|
||||
|
||||
@fields.depends('sales','amount')
|
||||
def on_change_sales(self):
|
||||
if self.amount:
|
||||
|
@ -1295,11 +1293,11 @@ class MultiplePaymentSaleStart(ModelView):
|
|||
self.balance = self.amount - sum(s.amount_to_pay for s in self.sales if s.amount_to_pay)
|
||||
|
||||
|
||||
class SelectMultiplePaymentSale(ModelView):
|
||||
class SelectMultiplePaymentSale(ModelView):
|
||||
'Select Multiple Payment Sale'
|
||||
__name__ = 'select_multiple_payment_sale'
|
||||
|
||||
line = fields.Many2One('multiple_payment_sale.start', 'Line Id')
|
||||
line = fields.Many2One('multiple_payment_sale.start', 'Line Id')
|
||||
sale = fields.Many2One('sale.sale', 'Sale', domain=[
|
||||
('state', 'in', ['confirmed', 'processing']),
|
||||
('party', '=', Eval('party')),
|
||||
|
@ -1332,13 +1330,13 @@ class SelectMultiplePaymentSale(ModelView):
|
|||
self.residual_amount = None
|
||||
self.amount_to_pay = None
|
||||
|
||||
@fields.depends('amount_to_pay','line', 'residual_amount')
|
||||
@fields.depends('amount_to_pay','line', 'residual_amount')
|
||||
def on_change_amount_to_pay(self):
|
||||
if self.amount_to_pay > self.line.balance or self.amount_to_pay > self.residual_amount:
|
||||
self.amount_to_pay = None
|
||||
|
||||
|
||||
class MultiplePaymentSale(Wizard):
|
||||
self.amount_to_pay = None
|
||||
|
||||
|
||||
class MultiplePaymentSale(Wizard):
|
||||
'Multiple Payment Sale'
|
||||
__name__ = 'multiple_payment_sale'
|
||||
start = StateView('multiple_payment_sale.start',
|
||||
|
@ -1353,14 +1351,14 @@ class MultiplePaymentSale(Wizard):
|
|||
Button('Add', 'add_sales', 'tryton-ok', default=True),
|
||||
])
|
||||
|
||||
create_moves= StateTransition()
|
||||
create_moves= StateTransition()
|
||||
add_sales = StateTransition()
|
||||
|
||||
def default_select_sales_ask(self, fields):
|
||||
return {
|
||||
'party': self.start.party.id,
|
||||
'statement': self.start.statement.id }
|
||||
|
||||
|
||||
def default_start(self, fields):
|
||||
default = {}
|
||||
if hasattr(self.select_sales_ask, 'party'):
|
||||
|
@ -1370,7 +1368,7 @@ class MultiplePaymentSale(Wizard):
|
|||
if hasattr(self.select_sales_ask, 'sales'):
|
||||
default.update({'sales': [{'sale': s.id, 'party': self.select_sales_ask.party.id} for s in self.select_sales_ask.sales]})
|
||||
return default
|
||||
|
||||
|
||||
@classmethod
|
||||
def execute(cls, session_id, data, state_name):
|
||||
result = super().execute(session_id, data, state_name)
|
||||
|
@ -1382,7 +1380,7 @@ class MultiplePaymentSale(Wizard):
|
|||
sale_domain.append(('party', '=', result['view']['defaults']['party']))
|
||||
result['view']['fields_view']['fields']['sales']['domain']= sale_domain
|
||||
return result
|
||||
|
||||
|
||||
def transition_create_moves(self):
|
||||
pool = Pool()
|
||||
StatementLine = pool.get('account.statement.line')
|
||||
|
@ -1406,8 +1404,8 @@ class MultiplePaymentSale(Wizard):
|
|||
return 'end'
|
||||
|
||||
def transition_add_sales(self):
|
||||
return 'start'
|
||||
|
||||
return 'start'
|
||||
|
||||
|
||||
class SelectSalesAsk(ModelView):
|
||||
'Select Sales Ask'
|
||||
|
|
5
shop.py
5
shop.py
|
@ -1,6 +1,5 @@
|
|||
# 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.
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from trytond.model import ModelView, ModelSQL, fields
|
||||
from trytond.pyson import Eval, Bool, Id
|
||||
from trytond.transaction import Transaction
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
# -*- 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.
|
||||
# This file is part of 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
|
||||
|
|
13
statement.py
13
statement.py
|
@ -1,13 +1,9 @@
|
|||
# This file is part of the sale_pos module for Tryton.
|
||||
# The COPYRIGHT file at the top level of this repository contains the full
|
||||
# copyright notices and license terms.
|
||||
from datetime import date
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from decimal import Decimal
|
||||
|
||||
from trytond.model import fields, ModelView, ModelSQL, Workflow
|
||||
from trytond.model import fields
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.wizard import Button, StateTransition, StateView, Wizard
|
||||
from trytond.pyson import Eval
|
||||
from trytond.i18n import gettext
|
||||
from trytond.exceptions import UserError
|
||||
|
@ -98,7 +94,6 @@ class StatementLine(metaclass=PoolMeta):
|
|||
Move = pool.get('account.move')
|
||||
MoveLine = pool.get('account.move.line')
|
||||
Period = pool.get('account.period')
|
||||
Journal = pool.get('account.statement.journal')
|
||||
|
||||
company_id = self.statement.company.id
|
||||
period_id = Period.find(company_id, date=self.date)
|
||||
|
@ -138,7 +133,7 @@ class StatementLine(metaclass=PoolMeta):
|
|||
|
||||
journals = self.statement.sale_device.journals
|
||||
journals = [j for j in journals if j.kind == 'cash']
|
||||
|
||||
|
||||
# Just add extra amount to move line when payment is different to cash
|
||||
if journals:
|
||||
journal = journals[0]
|
||||
|
|
9
stock.py
9
stock.py
|
@ -1,6 +1,5 @@
|
|||
# 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.
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from trytond.model import fields
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.pyson import Eval
|
||||
|
@ -10,8 +9,7 @@ class ShipmentOut(metaclass=PoolMeta):
|
|||
__name__ = 'stock.shipment.out'
|
||||
|
||||
shop_addresses = fields.Function(fields.Many2Many('party.address', None,
|
||||
None, 'Shop Addresses'),
|
||||
'on_change_with_shop_addresses')
|
||||
None, 'Shop Addresses'), 'on_change_with_shop_addresses')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
|
@ -43,7 +41,6 @@ class ShipmentOut(metaclass=PoolMeta):
|
|||
|
||||
class ShipmentOutReturn(metaclass=PoolMeta):
|
||||
__name__ = 'stock.shipment.out.return'
|
||||
|
||||
shop_addresses = fields.Function(fields.Many2Many('party.address', None,
|
||||
None, 'Shop Addresses'),
|
||||
'on_change_with_shop_addresses')
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[tryton]
|
||||
version=6.0.12
|
||||
version=6.0.13
|
||||
depends:
|
||||
company
|
||||
account_invoice
|
||||
|
|
5
user.py
5
user.py
|
@ -1,6 +1,5 @@
|
|||
# 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.
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from trytond.model import fields
|
||||
from trytond.pyson import Eval
|
||||
from trytond.pool import PoolMeta
|
||||
|
|
Loading…
Reference in New Issue