Update version minor fixes

This commit is contained in:
oscar alvarez 2023-10-20 18:34:16 -05:00
parent 182dc49e6f
commit 72a79ce75e
11 changed files with 59 additions and 58 deletions

View File

@ -1,4 +1,4 @@
Copyright (C) 2012 Zikzakmedia SL.
Copyright (C) 2019-2023 PRESIK SAS
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@ -4,7 +4,7 @@ Installing trytond_sale_shop
Prerequisites
-------------
* Python 2.6 or later (http://www.python.org/)
* Python 3.10 or later (http://www.python.org/)
* trytond (http://www.tryton.org/)
Installation

View File

@ -10,7 +10,6 @@ from . import invoice
from . import price_list
from . import product
from . import source
from . import goal
from . import statement

View File

@ -17,7 +17,6 @@ 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')
@ -80,7 +79,7 @@ class PriceListBySupplierStart(ModelView):
__name__ = 'sale_shop.price_list_by_supplier.start'
company = fields.Many2One('company.company', 'Company', required=True)
price_list = fields.Many2One('product.price_list', 'Price List')
suppliers = fields.Many2Many('party.party',None, None, 'Supplier')
suppliers = fields.Many2Many('party.party', None, None, 'Supplier')
@staticmethod
def default_company():
@ -90,7 +89,8 @@ class PriceListBySupplierStart(ModelView):
class PriceListBySupplier(Wizard):
'Price List By Supplier'
__name__ = 'sale_shop.price_list_by_supplier'
start = StateView('sale_shop.price_list_by_supplier.start',
start = StateView(
'sale_shop.price_list_by_supplier.start',
'sale_shop.print_price_list_start_view_form', [
Button('Cancel', 'end', 'tryton-cancel'),
Button('Print', 'print_', 'tryton-print', default=True),

View File

@ -15,7 +15,7 @@ class Product(metaclass=PoolMeta):
def __init__(self, arg):
super(Product, self).__init__()
self.arg = arg
self.arg = arg # ??????
class UpdatePriceProductStart(ModelView):

70
sale.py
View File

@ -39,8 +39,7 @@ class Sale(metaclass=PoolMeta):
'readonly': Or(Bool(Eval('number')), Bool(Eval('lines'))),
}, depends=['number', 'lines'])
shop_address = fields.Function(fields.Many2One('party.address',
'Shop Address'),
'on_change_with_shop_address')
'Shop Address'), 'on_change_with_shop_address')
source = fields.Many2One('sale.source', 'Source')
payments = fields.One2Many('account.statement.line', 'sale', 'Payments')
paid_amount = fields.Function(fields.Numeric('Paid Amount', digits=(16, 2)),
@ -128,8 +127,7 @@ class Sale(metaclass=PoolMeta):
def default_shop_address():
User = Pool().get('res.user')
user = User(Transaction().user)
return (user.shop and user.shop.address and
user.shop.address.id or None)
return (user.shop and user.shop.address and user.shop.address.id or None)
@classmethod
def copy(cls, sales, default=None):
@ -257,7 +255,8 @@ class Sale(metaclass=PoolMeta):
raise SaleWriteError(
gettext('sale_shop.msg_sale_not_shop'))
elif sale.shop not in user.shops:
raise SaleWriteError(gettext('sale_shop.msg_edit_sale_by_shop'))
raise SaleWriteError(
gettext('sale_shop.msg_edit_sale_by_shop'))
super(Sale, cls).write(*args)
@classmethod
@ -286,7 +285,6 @@ class Sale(metaclass=PoolMeta):
class SaleLine(metaclass=PoolMeta):
__name__ = 'sale.line'
unit_price_w_tax = fields.Function(fields.Numeric('Unit Price with Tax',
digits=(16, Eval('_parent_sale', {}).get('currency_digits',
Eval('currency_digits', 2))),
@ -393,7 +391,8 @@ class SaleLine(metaclass=PoolMeta):
del result[key]
return result
@fields.depends('product', 'unit', 'quantity', 'description',
@fields.depends(
'product', 'unit', 'quantity', 'description',
'_parent_sale.party', '_parent_sale.currency', '_parent_sale.sale_date')
def on_change_product(self):
super(SaleLine, self).on_change_product()
@ -420,7 +419,7 @@ class SaleBySupplierStart(ModelView):
suppliers = fields.Many2Many('party.party', None, None, 'Suppliers')
shop = fields.Many2One('sale.shop', 'Shop')
company = fields.Many2One('company.company', 'Company', required=True)
detailed = fields.Boolean('Detailed', select=True)
detailed = fields.Boolean('Detailed')
@staticmethod
def default_company():
@ -435,7 +434,8 @@ class SaleBySupplierStart(ModelView):
class PrintSaleBySupplier(Wizard):
'Sale By Supplier'
__name__ = 'sale_shop.print_sale_by_supplier'
start = StateView('sale_shop.sale_by_supplier.start',
start = StateView(
'sale_shop.sale_by_supplier.start',
'sale_shop.print_sale_by_supplier_start_view_form', [
Button('Cancel', 'end', 'tryton-cancel'),
Button('Print', 'print_', 'tryton-print', default=True),
@ -477,8 +477,8 @@ class SaleBySupplier(Report):
('purchase.state', 'in', ('processing', 'done')),
], order=[('create_date', 'DESC')], limit=1)
if lines:
return (lines[0].purchase.purchase_date,
lines[0].quantity)
line = lines[0]
return (line.purchase.purchase_date, line.quantity)
else:
return None, None
@ -511,7 +511,6 @@ class SaleBySupplier(Report):
Company = pool.get('company.company')
Party = pool.get('party.party')
ProductSupplier = pool.get('purchase.product_supplier')
InvoiceLine = pool.get('account.invoice.line')
company = Company(data['company'])
cursor = Transaction().connection.cursor()
dom_suppliers = [
@ -519,7 +518,6 @@ class SaleBySupplier(Report):
]
total_sales = []
total_sales_append = total_sales.append
total_cost = []
parties_query = ''
start_date = data['start_date']
end_date = data['end_date']
@ -675,11 +673,12 @@ class SaleShopDetailedStart(ModelView):
class SaleShopDetailed(Wizard):
'Sale Shop Detailed'
__name__ = 'sale_shop.sale_detailed'
start = StateView('sale_shop.sale_detailed.start',
start = StateView(
'sale_shop.sale_detailed.start',
'sale_shop.sale_shop_detailed_start_view_form', [
Button('Cancel', 'end', 'tryton-cancel'),
Button('Print', 'print_', 'tryton-ok', default=True),
])
])
print_ = StateAction('sale_shop.report_sale_detailed')
def do_print_(self, action):
@ -817,12 +816,14 @@ class SaleBySellerStart(ModelView):
start_date = fields.Date('Start Date', required=True)
end_date = fields.Date('End Date', required=True)
company = fields.Many2One('company.company', 'Company', required=True)
shop = fields.Many2One('sale.shop', 'Shop',
depends=['company'], domain=[
shop = fields.Many2One('sale.shop', 'Shop', depends=['company'],
domain=[
('company', '=', Eval('company'))
])
salesmans = fields.Many2Many('company.employee', None, None, 'Salesmans')
payment_methods = fields.Many2Many('account.invoice.payment_term', None, None, 'Payment Method')
])
salesmans = fields.Many2Many(
'company.employee', None, None, 'Salesmans')
payment_methods = fields.Many2Many(
'account.invoice.payment_term', None, None, 'Payment Method')
@staticmethod
def default_company():
@ -832,15 +833,15 @@ class SaleBySellerStart(ModelView):
class SaleBySeller(Wizard):
'Sale By Seller'
__name__ = 'sale_shop.sale_by_seller.wizard'
start = StateView('sale_shop.sale_by_seller.start',
start = StateView(
'sale_shop.sale_by_seller.start',
'sale_shop.sale_by_seller_start_view_form', [
Button('Cancel', 'end', 'tryton-cancel'),
Button('Print', 'print_', 'tryton-ok', default=True),
])
])
print_ = StateAction('sale_shop.sale_by_seller_report_')
def do_print_(self, action):
data = {
'ids': [],
'company': self.start.company.id,
@ -969,11 +970,12 @@ class SaleMonthByShopStart(ModelView):
class SaleMonthByShop(Wizard):
'Sale MonthByShop'
__name__ = 'sale_shop.sale_month_shop'
start = StateView('sale_shop.sale_month_shop.start',
start = StateView(
'sale_shop.sale_month_shop.start',
'sale_shop.sale_month_shop_start_view_form', [
Button('Cancel', 'end', 'tryton-cancel'),
Button('Print', 'print_', 'tryton-ok', default=True),
])
])
print_ = StateReport('sale_shop.sale_month_shop_report')
def do_print_(self, action):
@ -1177,7 +1179,8 @@ class SalePaymentForm(ModelView):
class WizardSalePayment(Wizard):
'Wizard Sale Payment'
__name__ = 'sale.payment'
start = StateView('sale.payment.form',
start = StateView(
'sale.payment.form',
'sale_shop.sale_payment_view_form', [
Button('Cancel', 'end', 'tryton-cancel'),
Button('Pay', 'pay_', 'tryton-ok', default=True),
@ -1203,7 +1206,7 @@ class WizardSalePayment(Wizard):
dom_statement.append(('sale_device', '=', sale.sale_device.id))
if result.get('view'):
result['view']['fields_view']['fields']['statement']['domain']= dom_statement
result['view']['fields_view']['fields']['statement']['domain'] = dom_statement
return result
def default_start(self, fields):
@ -1342,7 +1345,7 @@ 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
@ -1363,7 +1366,7 @@ class MultiplePaymentSale(Wizard):
'sale_shop.select_sales_ask_view_form', [
Button('Add', 'add_sales', 'tryton-ok', default=True),
])
create_moves= StateTransition()
create_moves = StateTransition()
add_sales = StateTransition()
def default_select_sales_ask(self, fields):
@ -1426,7 +1429,8 @@ class MultiplePaymentSale(Wizard):
class SelectSalesAsk(ModelView):
'Select Sales Ask'
__name__ = 'sale.shop.select_sales.ask'
sales = fields.Many2Many('sale.sale', None, None,
'Sales')
party = fields.Many2One('party.party', 'Party', readonly=True, states={'invisible': True})
statement = fields.Many2One('account.statement', 'Statement', readonly=True, states={'invisible': True})
sales = fields.Many2Many('sale.sale', None, None, 'Sales')
party = fields.Many2One('party.party', 'Party', readonly=True,
states={'invisible': True})
statement = fields.Many2One('account.statement', 'Statement',
readonly=True, states={'invisible': True})

15
shop.py
View File

@ -10,7 +10,7 @@ from trytond import backend
class SaleShop(ModelSQL, ModelView):
'Sale Shop'
__name__ = 'sale.shop'
name = fields.Char('Shop Name', required=True, select=True)
name = fields.Char('Shop Name', required=True)
users = fields.Many2Many('sale.shop-res.user', 'shop', 'user', 'Users')
address = fields.Many2One('party.address', 'Address', domain=[
('party', '=', Eval('company_party')),
@ -45,10 +45,9 @@ class SaleShop(ModelSQL, ModelView):
company = fields.Many2One('company.company', 'Company', required=True,
domain=[], select=True)
company_party = fields.Function(fields.Many2One('party.party',
'Company Party'),
'on_change_with_company_party')
active = fields.Boolean('Active', select=True)
self_pick_up = fields.Boolean('Self Pickup', select=True)
'Company Party'), 'on_change_with_company_party')
active = fields.Boolean('Active')
self_pick_up = fields.Boolean('Self Pickup')
sale_return_sequence = fields.Many2One('ir.sequence',
'Sale Return Sequence', domain=[
('company', 'in',
@ -73,7 +72,7 @@ class SaleShop(ModelSQL, ModelView):
shop_table = cls.__table__()
table_h = cls.__table_handler__(module_name)
company_table = Company.__table__()
# validate column only in version 6.0.14
# validate column only in version 6.0.14
if table_h.column_exist('datafono'):
table_h.column_rename('datafono', 'pos_terminal')
@ -113,7 +112,7 @@ class SaleShopResUser(ModelSQL):
__name__ = 'sale.shop-res.user'
_table = 'sale_shop_res_user'
shop = fields.Many2One('sale.shop', 'Shop', ondelete='CASCADE',
select=True, required=True)
required=True)
user = fields.Many2One('res.user', 'User', ondelete='RESTRICT',
required=True)
@ -123,7 +122,7 @@ class SaleShopEmployee(ModelSQL):
__name__ = 'sale.shop.company_employee'
_table = 'sale_shop_company_employee'
shop = fields.Many2One('sale.shop', 'Shop', ondelete='CASCADE',
select=True, required=True)
required=True)
salesman = fields.Many2One('company.employee', 'Salesman', states={
'readonly': Eval('state').in_(['confirmed', 'processing', 'done']),
}, ondelete='RESTRICT', required=True)

View File

@ -33,7 +33,7 @@ class SaleSource(Workflow, ModelSQL, ModelView):
_rec_name = 'name'
name = fields.Char('Name', required=True)
active = fields.Boolean('Active')
type = fields.Selection(SOURCES, 'Type', select=True, required=True)
type = fields.Selection(SOURCES, 'Type', required=True)
company = fields.Many2One('company.company', 'Company', required=True)
party = fields.Many2One('party.party', 'Party')
payment_term = fields.Many2One('account.invoice.payment_term',

View File

@ -34,7 +34,7 @@ class Journal(metaclass=PoolMeta):
('transfer', 'Transfer'),
('payment', 'Payment'),
('other', 'Other'),
], 'Kind', select=True)
], 'Kind')
default_start_balance = fields.Numeric('Default Start Balance by Device')
require_voucher = fields.Boolean('Require Voucher')
require_party = fields.Boolean('Require Party')
@ -132,13 +132,13 @@ class StatementLine(metaclass=PoolMeta):
to_create = [move_line1, move_line2]
journals = self.statement.sale_device.journals if hasattr(self.statement, 'sale_device') else []
journals = [j for j in journals if j.kind == 'cash']
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]
if hasattr(self, 'extra_amount') and self.extra_amount and self.extra_amount > 0 and \
self.statement.journal.id != journal.id:
self.statement.journal.id != journal.id:
move_line3 = self.get_move_line2({
'account': journal.account,
'move_id': move.id,
@ -155,8 +155,9 @@ class StatementLine(metaclass=PoolMeta):
if s.invoice and s.move and s.invoice.state != 'paid':
invoice = s.invoice
move = s.move
payment_lines = [l for l in move.lines if l.account
== invoice.account and l.party == invoice.party]
payment_lines = [
l for l in move.lines if l.account == invoice.account and l.party == invoice.party
]
invoice.add_payment_lines({invoice: payment_lines})
def create_move(self):

View File

@ -7,7 +7,6 @@ from trytond.pyson import Eval
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')
@ -42,8 +41,7 @@ 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')
None, 'Shop Addresses'), 'on_change_with_shop_addresses')
@classmethod
def __setup__(cls):

View File

@ -1,5 +1,5 @@
[tryton]
version=6.0.16
version=6.0.17
depends:
company
account_invoice