Fix
This commit is contained in:
parent
ed1bbdf8da
commit
fe4b1cd2b1
|
@ -9,7 +9,6 @@ from . import account
|
|||
from . import tax
|
||||
from . import geographic_codes
|
||||
from . import product
|
||||
# from . import sale
|
||||
from . import invoice_authorization
|
||||
from . import asset
|
||||
from . import payment_term
|
||||
|
|
|
@ -22,7 +22,6 @@ from trytond.report import Report
|
|||
from trytond.pyson import Eval, Bool, PYSONEncoder
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
# from trytond.modules.account.account import BalanceSheetContext
|
||||
from trytond.exceptions import UserError
|
||||
from .exceptions import (BadOperationError, DontWriteAccountError)
|
||||
|
||||
|
|
1
asset.py
1
asset.py
|
@ -1,7 +1,6 @@
|
|||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.model import ModelView, ModelSQL, fields
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from datetime import timedelta
|
||||
from trytond.pyson import Eval, Bool
|
||||
|
||||
|
||||
|
|
24
audit.py
24
audit.py
|
@ -1,12 +1,10 @@
|
|||
from trytond.transaction import Transaction
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.model import ModelView, ModelSQL, fields
|
||||
from trytond.wizard import Wizard, StateView, Button, StateReport, StateTransition
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from datetime import timedelta
|
||||
from trytond.pyson import Eval, Bool
|
||||
from trytond.pool import Pool
|
||||
from trytond.model import ModelView, fields
|
||||
from trytond.wizard import Wizard, StateView, Button, StateReport
|
||||
from trytond.report import Report
|
||||
|
||||
|
||||
class AuditReportStart(ModelView):
|
||||
'Audit Report Start'
|
||||
__name__ = 'account_col.audit_report_start'
|
||||
|
@ -24,11 +22,12 @@ class AuditReportWizard(Wizard):
|
|||
'Audit Report Wizard'
|
||||
__name__ = 'account_col.audit_report_wizard'
|
||||
|
||||
start = StateView('account_col.audit_report_start',
|
||||
start = StateView(
|
||||
'account_col.audit_report_start',
|
||||
'account_col.print_audit_report_start_view_form', [
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Print', 'print_', 'tryton-print', default=True),
|
||||
])
|
||||
])
|
||||
print_ = StateReport('account_col.audit_report')
|
||||
|
||||
def do_print_(self, action):
|
||||
|
@ -40,7 +39,7 @@ class AuditReportWizard(Wizard):
|
|||
'time_now': self.start.company.time_now()
|
||||
}
|
||||
return action, data
|
||||
|
||||
|
||||
def transition_print_(self):
|
||||
return 'end'
|
||||
|
||||
|
@ -62,13 +61,12 @@ class AuditReport(Report):
|
|||
Invoice = pool.get('account.invoice')
|
||||
Move = pool.get('account.move')
|
||||
ShipmentInternal = pool.get('stock.shipment.internal')
|
||||
Accounts = pool.get('account.account')
|
||||
today = pool.get('ir.date').today()
|
||||
|
||||
cursor = Transaction().connection.cursor()
|
||||
|
||||
query = """SELECT m.number, c.code, c.id, c.name FROM account_move_line as ml
|
||||
join account_move as m on ml.move=m.id
|
||||
query = """SELECT m.number, c.code, c.id, c.name FROM account_move_line as ml
|
||||
join account_move as m on ml.move=m.id
|
||||
join account_account as c on ml.account=c.id where c.type is null"""
|
||||
cursor.execute(query)
|
||||
columns = list(cursor.description)
|
||||
|
@ -142,4 +140,4 @@ class AuditReport(Report):
|
|||
report_context['shipments'] = shipments
|
||||
report_context['accounts'] = list(accounts.values())
|
||||
report_context['moves_future'] = moves_future
|
||||
return report_context
|
||||
return report_context
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
# this repository contains the full copyright notices and license terms.
|
||||
from trytond.model import ModelView, ModelSQL, fields
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pool import Pool
|
||||
from sql import Null
|
||||
|
||||
|
||||
|
|
|
@ -7,10 +7,9 @@ from datetime import date, timedelta
|
|||
from trytond.i18n import gettext
|
||||
from trytond.model import ModelView, ModelSQL, fields, dualmethod
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.pyson import Eval, And, If, Bool
|
||||
from trytond.pyson import Eval, If, Bool
|
||||
from trytond.wizard import Wizard, StateView, Button, StateReport, StateTransition
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.report import Report
|
||||
from trytond.modules.company import CompanyReport
|
||||
from trytond.exceptions import UserError
|
||||
|
||||
|
@ -397,7 +396,7 @@ class Invoice(metaclass=PoolMeta):
|
|||
class InvoiceLine(ModelSQL, ModelView):
|
||||
__name__ = 'account.invoice.line'
|
||||
|
||||
@classmethod
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(InvoiceLine, cls).__setup__()
|
||||
|
||||
|
|
35
move.py
35
move.py
|
@ -13,7 +13,6 @@ from trytond.modules.company import CompanyReport
|
|||
from trytond.transaction import Transaction
|
||||
from trytond.wizard import Wizard, StateTransition, StateView, Button
|
||||
from trytond.pyson import Eval
|
||||
from trytond.i18n import gettext
|
||||
from trytond.exceptions import UserError
|
||||
|
||||
_ZERO = Decimal('0.0')
|
||||
|
@ -40,10 +39,6 @@ class Move(ModelSQL, ModelView):
|
|||
})
|
||||
method_string = method.translated('method')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(Move, cls).__setup__()
|
||||
|
||||
@fields.depends('lines')
|
||||
def on_change_with_balance(self, name=None):
|
||||
res = Decimal('0.0')
|
||||
|
@ -96,7 +91,7 @@ class Line(ModelSQL, ModelView):
|
|||
lines_check = []
|
||||
for m in moves:
|
||||
lines_check + list(m.lines)
|
||||
modified_fields = {'reconciliation','account'}
|
||||
modified_fields = {'reconciliation', 'account'}
|
||||
cls.check_modify(lines, modified_fields=modified_fields)
|
||||
cls.check_reconciliation(lines, modified_fields=modified_fields)
|
||||
ids = [l.id for l in lines]
|
||||
|
@ -262,7 +257,8 @@ class MoveFixNumberStart(ModelView):
|
|||
class MoveFixNumber(Wizard):
|
||||
'Move Fix Number'
|
||||
__name__ = 'account.move.fix_number'
|
||||
start = StateView('account_col.move.fix_number.start',
|
||||
start = StateView(
|
||||
'account_col.move.fix_number.start',
|
||||
'account_col.move_fix_number_start_view_form', [
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Ok', 'accept', 'tryton-ok', default=True),
|
||||
|
@ -286,9 +282,7 @@ class RenumberMoveStart(ModelView):
|
|||
'Renumber Move Start'
|
||||
__name__ = 'account_col.renumber_move.start'
|
||||
fiscalyear = fields.Many2One('account.fiscalyear', 'Fiscal Year',
|
||||
required=True, domain=[
|
||||
('state', '=', 'open'),
|
||||
])
|
||||
required=True, domain=[('state', '=', 'open')])
|
||||
start_number = fields.Integer('Start Number', required=True)
|
||||
journal = fields.Many2One('account.journal', 'Journal',
|
||||
required=True)
|
||||
|
@ -326,7 +320,8 @@ class RenumberMoveStart(ModelView):
|
|||
class RenumberMove(Wizard):
|
||||
'Renumber Move'
|
||||
__name__ = 'account_col.renumber_move'
|
||||
start = StateView('account_col.renumber_move.start',
|
||||
start = StateView(
|
||||
'account_col.renumber_move.start',
|
||||
'account_col.renumber_move_start_view_form', [
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Ok', 'accept', 'tryton-ok', default=True),
|
||||
|
@ -413,13 +408,15 @@ class MoveCloseYearStart(ModelView):
|
|||
class MoveCloseYear(Wizard):
|
||||
'Move Close Year'
|
||||
__name__ = 'account_col.move_close_year'
|
||||
start = StateView('account_col.move_close_year.start',
|
||||
start = StateView(
|
||||
'account_col.move_close_year.start',
|
||||
'account_col.move_close_year_start_view_form', [
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Ok', 'create_', 'tryton-print', default=True),
|
||||
])
|
||||
create_ = StateTransition()
|
||||
done = StateView('account_col.move_close_year.done',
|
||||
done = StateView(
|
||||
'account_col.move_close_year.done',
|
||||
'account_col.move_close_year_done_view_form', [
|
||||
Button('Done', 'end', 'tryton-ok', default=True),
|
||||
])
|
||||
|
@ -477,7 +474,7 @@ class MoveCloseYear(Wizard):
|
|||
move_line.account,
|
||||
move_line.party,
|
||||
Sum(move_line.credit).as_('credit'),
|
||||
Sum(move_line.debit).as_('debit'),
|
||||
Sum(move_line.debit).as_('debit'),
|
||||
ArrayAgg(move_line.id).as_('ids')
|
||||
]
|
||||
|
||||
|
@ -485,15 +482,15 @@ class MoveCloseYear(Wizard):
|
|||
group_by=[move_line.account, move_line.party]))
|
||||
|
||||
query_3 = withs_.select(withs_.account, withs_.party,
|
||||
Case((withs_.credit < withs_.debit , withs_.debit - withs_.credit),else_=0).as_('credit'),
|
||||
Case((withs_.credit > withs_.debit , withs_.credit - withs_.debit) ,else_=0).as_('debit'),
|
||||
Case((withs_.credit < withs_.debit, withs_.debit - withs_.credit),else_=0).as_('credit'),
|
||||
Case((withs_.credit > withs_.debit, withs_.credit - withs_.debit) ,else_=0).as_('debit'),
|
||||
withs_.ids,
|
||||
with_=[withs_]
|
||||
)
|
||||
|
||||
cursor.execute(*query_3)
|
||||
result2 = cursor.fetchall()
|
||||
query_4 = withs_.select( Sum(withs_.credit - withs_.debit), with_=[withs_])
|
||||
query_4 = withs_.select(Sum(withs_.credit - withs_.debit), with_=[withs_])
|
||||
cursor.execute(*query_4)
|
||||
balance = cursor.fetchone()[0]
|
||||
print(result2, 'total parties-account')
|
||||
|
@ -512,7 +509,7 @@ class MoveCloseYear(Wizard):
|
|||
lines_to_create = [{'party': r[1], 'account': r[0], 'credit': r[2], 'debit': r[3], 'state':'valid', 'move': move_id} \
|
||||
for r in result2 if (r[2] > 0 or r[3]>0)]
|
||||
concile_direct = [r[4] for r in result2 if (r[2]==0 and r[3] == 0)]
|
||||
lines_to_concile = {str(r[1]) + '_' +str(r[0]): r[4] for r in result2}
|
||||
lines_to_concile = {str(r[1]) + '_' + str(r[0]): r[4] for r in result2}
|
||||
|
||||
profit_line = {
|
||||
'account': self.start.expense_account.id,
|
||||
|
@ -526,7 +523,7 @@ class MoveCloseYear(Wizard):
|
|||
else:
|
||||
profit_line['debit'] = abs(balance)
|
||||
start_time = time.time()
|
||||
print(start_time -initial_time, 'initial time')
|
||||
print(start_time - initial_time, 'initial time')
|
||||
lines = MoveLine.create(lines_to_create)
|
||||
|
||||
MoveLine.create([profit_line])
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# this repository contains the full copyright notices and license terms.
|
||||
from decimal import Decimal
|
||||
from trytond.model import fields
|
||||
from trytond.pool import PoolMeta, Pool
|
||||
from trytond.pool import PoolMeta
|
||||
from trytond.pyson import Eval
|
||||
from trytond.exceptions import UserError
|
||||
from trytond.i18n import gettext
|
||||
|
@ -114,7 +114,7 @@ class ProductCategory(metaclass=PoolMeta):
|
|||
},
|
||||
depends=['account_parent', 'accounting'])
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class ProductTemplate(metaclass=PoolMeta):
|
||||
|
|
354
sale.py
354
sale.py
|
@ -1,354 +0,0 @@
|
|||
# # 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, ModelSQL, ModelView
|
||||
# from trytond.pool import PoolMeta, Pool
|
||||
# from trytond.pyson import Eval
|
||||
# from trytond.wizard import Wizard, StateTransition, StateView, Button
|
||||
# from trytond.transaction import Transaction
|
||||
# from trytond.exceptions import UserError
|
||||
# from trytond.i18n import gettext
|
||||
# from sql import Table
|
||||
# from decimal import Decimal
|
||||
|
||||
# from . import invoice
|
||||
|
||||
# conversor = None
|
||||
# try:
|
||||
# from numword import numword_es
|
||||
# conversor = numword_es.NumWordES()
|
||||
# except:
|
||||
# print("Warning: Does not possible import numword module!")
|
||||
# print("Please install it...!")
|
||||
|
||||
# TYPE_INVOICE = invoice.TYPE_INVOICE_OUT
|
||||
|
||||
|
||||
# class Sale(metaclass=PoolMeta):
|
||||
# __name__ = 'sale.sale'
|
||||
# invoice_type = fields.Selection(TYPE_INVOICE, 'Type Invoice',
|
||||
# states={
|
||||
# 'readonly': Eval('state').in_(
|
||||
# ['confirmed', 'processing', 'done', 'cancel']
|
||||
# )
|
||||
# })
|
||||
# vouchers = fields.Many2Many('sale.sale-account.voucher', 'sale',
|
||||
# 'voucher', 'Vouchers', domain=[], states={
|
||||
# 'readonly': Eval('state') == 'done'
|
||||
# }, depends=['party'])
|
||||
# total_amount_words = fields.Function(fields.Char('Total Amount Words'),
|
||||
# 'get_total_amount_words')
|
||||
# sale_taxes = fields.Function(fields.Dict(None, 'Taxes'), 'get_sale_taxes')
|
||||
|
||||
# total_discount = fields.Function(fields.Numeric('Total Discount',
|
||||
# digits=(16, 2)), 'get_total_discount')
|
||||
|
||||
# @classmethod
|
||||
# def __setup__(cls):
|
||||
# super(Sale, cls).__setup__()
|
||||
|
||||
# def get_sale_taxes(self, name):
|
||||
# sale_taxes = {}
|
||||
# for l in self.lines:
|
||||
# for t in l.taxes:
|
||||
# if t.id not in sale_taxes.keys():
|
||||
# sale_taxes[t.id] = {
|
||||
# 'description': t.description,
|
||||
# 'base': 0,
|
||||
# 'value_tax': 0,
|
||||
# 'percent': t.rate,
|
||||
# }
|
||||
# # quantity = Decimal(l.quantity)
|
||||
# sale_taxes[t.id]['base'] += l.amount
|
||||
# if t.type == 'percentage':
|
||||
# sale_taxes[t.id]['value_tax'] += (l.amount * t.rate)
|
||||
# else:
|
||||
# sale_taxes[t.id]['value_tax'] += (l.product.extra_tax if l.product.extra_tax else 0)
|
||||
|
||||
# return sale_taxes.values()
|
||||
|
||||
# def get_total_amount_words(self, name=None):
|
||||
# if conversor and self.total_amount:
|
||||
# num = (conversor.cardinal(int(self.total_amount))).upper()
|
||||
# return num
|
||||
|
||||
# def get_total_discount(self, name=None):
|
||||
# res = []
|
||||
# for line in self.lines:
|
||||
# if hasattr(line, 'discount_amount') and line.discount_amount:
|
||||
# res.append(line.discount_amount)
|
||||
# res = Decimal(sum(res)).quantize(Decimal(str(10.0 ** -2)))
|
||||
# return res
|
||||
|
||||
# @classmethod
|
||||
# def copy(cls, sales, default=None):
|
||||
# if default is None:
|
||||
# default = {}
|
||||
# default = default.copy()
|
||||
# default['invoice_type'] = None
|
||||
# # default['vouchers'] = None
|
||||
# return super(Sale, cls).copy(sales, default=default)
|
||||
|
||||
# # @classmethod
|
||||
# # def proceed(cls, sales):
|
||||
# # for sale in sales:
|
||||
# # if sale.state == 'confirmed' and sale.shipment_method == 'order':
|
||||
# # sale.party.check_credit_limit(sale.untaxed_amount,
|
||||
# # origin=str(sale))
|
||||
# # return super(Sale, cls).proceed(sales)
|
||||
|
||||
# # @staticmethod
|
||||
# # def default_authorization():
|
||||
# # Authorization = Pool().get('account.invoice.authorization')
|
||||
# # auths = Authorization.search([
|
||||
# # ('state', '=', 'active'),
|
||||
# # ('kind', '=', self.invoice_type)
|
||||
# # ])
|
||||
# # if self.invoice_type and auths:
|
||||
# # return auths[0].id
|
||||
# # else:
|
||||
# # return None
|
||||
|
||||
# def _get_invoice_sale(self):
|
||||
# invoice = super(Sale, self)._get_invoice_sale()
|
||||
# invoice.invoice_type = self.invoice_type
|
||||
|
||||
# if (hasattr(self, 'shop') and hasattr(self.shop, 'computer_authorization') and hasattr(self.shop, 'pos_authorization')
|
||||
# and hasattr(self.shop, 'credit_note_electronic_authorization') and hasattr(self.shop, 'electronic_authorization') and hasattr(self.shop, 'manual_authorization')):
|
||||
# if self.invoice_type == 'C' and self.shop.computer_authorization and self.shop.computer_authorization.state == 'active':
|
||||
# invoice.authorization = self.shop.computer_authorization
|
||||
# if self.invoice_type == 'P' and self.shop.pos_authorization and self.shop.pos_authorization.state == 'active':
|
||||
# invoice.authorization = self.shop.pos_authorization
|
||||
# elif self.invoice_type == 'M' and self.shop.manual_authorization and self.shop.manual_authorization.state == 'active':
|
||||
# invoice.authorization = self.shop.manual_authorization
|
||||
# elif self.invoice_type == 'N' and self.shop.credit_note_electronic_authorization and self.shop.credit_note_electronic_authorization.state == 'active':
|
||||
# invoice.authorization = self.shop.credit_note_electronic_authorization
|
||||
# elif self.invoice_type in ['1', '2', '3'] and self.shop.electronic_authorization and self.shop.electronic_authorization.state == 'active':
|
||||
# invoice.authorization = self.shop.electronic_authorization
|
||||
# else:
|
||||
# invoice.authorization = None
|
||||
# else:
|
||||
# if self.invoice_type:
|
||||
# Authorization = Pool().get('account.invoice.authorization')
|
||||
# auths = Authorization.search([
|
||||
# ('company', '=', self.company.id),
|
||||
# ('state', '=', 'active'),
|
||||
# ('kind', '=', self.invoice_type)
|
||||
# ])
|
||||
# if auths:
|
||||
# invoice.authorization = auths[0].id
|
||||
|
||||
# return invoice
|
||||
|
||||
# def get_total_vouchers_amount(self):
|
||||
# amount_ = 0
|
||||
# for v in self.vouchers:
|
||||
# amount_ += v.amount_to_pay
|
||||
# return amount_
|
||||
|
||||
# def on_change_party(self, name=None):
|
||||
# super(Sale, self).on_change_party()
|
||||
# if self.party and self.party.invoice_type:
|
||||
# self.invoice_type = self.party.invoice_type
|
||||
# else:
|
||||
# self.invoice_type = None
|
||||
|
||||
# @classmethod
|
||||
# def quote(cls, sales):
|
||||
# super(Sale, cls).quote(sales)
|
||||
# for sale in sales:
|
||||
# if sale.invoice_type == "" or sale.invoice_type is None:
|
||||
# raise UserError('Tipo de factura inválido!')
|
||||
# return
|
||||
|
||||
|
||||
# class SaleLine(metaclass=PoolMeta):
|
||||
# __name__ = 'sale.line'
|
||||
|
||||
# @fields.depends('description')
|
||||
# def on_change_product(self):
|
||||
# super(SaleLine, self).on_change_product()
|
||||
# if self.product:
|
||||
# self.description = self.product.name
|
||||
# else:
|
||||
# self.description = None
|
||||
|
||||
# @fields.depends(methods=['compute_unit_price'])
|
||||
# def on_change_quantity(self):
|
||||
# if self.quantity > 0:
|
||||
# super(SaleLine, self).on_change_quantity()
|
||||
|
||||
|
||||
# class SaleVoucher(ModelSQL):
|
||||
# 'Sale - Voucher'
|
||||
# __name__ = 'sale.sale-account.voucher'
|
||||
# _table = 'sale_vouchers_rel'
|
||||
# sale = fields.Many2One('sale.sale', 'Sale', ondelete='CASCADE',
|
||||
# select=True, required=True)
|
||||
# voucher = fields.Many2One('account.voucher', 'Voucher', select=True,
|
||||
# domain=[('voucher_type', '=', 'receipt')], ondelete='RESTRICT',
|
||||
# required=True)
|
||||
|
||||
# @classmethod
|
||||
# def set_voucher_origin(cls, voucher_id, target_id):
|
||||
# cls.create([{
|
||||
# 'voucher': voucher_id,
|
||||
# 'sale': target_id,
|
||||
# }])
|
||||
|
||||
|
||||
# class SaleUpdateStart(ModelView):
|
||||
# 'Sale Update Start'
|
||||
# __name__ = 'sale.update.start'
|
||||
# date = fields.Date('Date')
|
||||
# description = fields.Char('Description')
|
||||
# tax_add = fields.Many2One('account.tax', 'Add Tax', domain=[
|
||||
# ('group.kind', '=', Eval('group_tax'))
|
||||
# ], depends=['group_tax'])
|
||||
# tax_remove = fields.Many2One('account.tax', 'Remove Tax', domain=[
|
||||
# ('group.kind', '=', Eval('group_tax'))
|
||||
# ], depends=['group_tax'])
|
||||
# group_tax = fields.Char('Group Tax')
|
||||
|
||||
# @staticmethod
|
||||
# def default_group_tax():
|
||||
# return 'sale'
|
||||
|
||||
|
||||
# class SaleUpdate(Wizard):
|
||||
# 'Sale Update'
|
||||
# __name__ = 'sale.update'
|
||||
# start = StateView('sale.update.start',
|
||||
# 'account_col.sale_update_start_view_form', [
|
||||
# Button('Cancel', 'end', 'tryton-cancel'),
|
||||
# Button('Ok', 'accept', 'tryton-ok', default=True),
|
||||
# ])
|
||||
# accept = StateTransition()
|
||||
|
||||
# def _update_all_dates(self):
|
||||
# pass
|
||||
|
||||
# def transition_accept(self):
|
||||
# Sale = Pool().get('sale.sale')
|
||||
# Line = Pool().get('sale.line')
|
||||
# sales = Sale.browse(Transaction().context['active_ids'])
|
||||
|
||||
# values = {}
|
||||
# if self.start.date:
|
||||
# values['sale_date'] = self.start.date
|
||||
# if self.start.description:
|
||||
# values['description'] = self.start.description
|
||||
|
||||
# sales = [s for s in sales if s.state == 'draft']
|
||||
# if values:
|
||||
# Sale.write(sales, values)
|
||||
|
||||
# if (self.start.tax_add or self.start.tax_remove) and sales:
|
||||
# sale = sales[0]
|
||||
# lines_to_change = []
|
||||
# for line in sale.lines:
|
||||
# if line.type != 'line':
|
||||
# continue
|
||||
# lines_to_change.append(line)
|
||||
|
||||
# if lines_to_change:
|
||||
# if self.start.tax_add:
|
||||
# Line.write(lines_to_change, {'taxes': [
|
||||
# ('add', [self.start.tax_add.id])]})
|
||||
# if self.start.tax_remove:
|
||||
# Line.write(lines_to_change, {'taxes': [
|
||||
# ('remove', [self.start.tax_remove.id])]})
|
||||
# sale.save()
|
||||
# return 'end'
|
||||
|
||||
|
||||
# class SaleForceDraft(Wizard):
|
||||
# 'Sale Force Draft'
|
||||
# __name__ = 'account_col.force_draft'
|
||||
# start_state = 'force_draft'
|
||||
# force_draft = StateTransition()
|
||||
|
||||
# @classmethod
|
||||
# def __setup__(cls):
|
||||
# super(SaleForceDraft, cls).__setup__()
|
||||
|
||||
# def transition_force_draft(self):
|
||||
# sale_table = Table('sale_sale')
|
||||
# invoice_table = Table('account_invoice')
|
||||
# move_table = Table('account_move')
|
||||
# stock_move_table = Table('stock_move')
|
||||
# Sale = Pool().get('sale.sale')
|
||||
|
||||
# cursor = Transaction().connection.cursor()
|
||||
# ids = Transaction().context['active_ids']
|
||||
# if not ids:
|
||||
# return 'end'
|
||||
# sales = Sale.browse(ids)
|
||||
|
||||
# for sale in sales:
|
||||
# # if sale.sale_date != Date.today():
|
||||
# # return 'end'
|
||||
|
||||
# # The payments must be delete
|
||||
# # if hasattr(sale, 'payments'):
|
||||
# # for pay in sale.payments:
|
||||
# # if pay.statement.state != 'draft':
|
||||
# # return 'end'
|
||||
# # if pay.move:
|
||||
# # self.unreconcile_move(pay.move)
|
||||
# # pay.invoice = None
|
||||
# # pay.save()
|
||||
# # pay.move.delete([pay.move])
|
||||
# # pay.delete([pay])
|
||||
|
||||
# # The invoices must be delete
|
||||
# for invoice in sale.invoices:
|
||||
# if (hasattr(invoice, 'cufe') and invoice.cufe) or \
|
||||
# hasattr(invoice, 'electronic_state') and \
|
||||
# invoice.electronic_state == 'submitted':
|
||||
# raise UserError(
|
||||
# gettext('account_col.msg_with_electronic_invoice'))
|
||||
# if invoice.state == 'paid':
|
||||
# self.unreconcile_move(invoice.move)
|
||||
# if invoice.move:
|
||||
# cursor.execute(*move_table.update(
|
||||
# columns=[move_table.state],
|
||||
# values=['draft'],
|
||||
# where=move_table.id == invoice.move.id)
|
||||
# )
|
||||
# cursor.execute(*move_table.delete(
|
||||
# where=move_table.id == invoice.move.id)
|
||||
# )
|
||||
# cursor.execute(*invoice_table.update(
|
||||
# columns=[invoice_table.state, invoice_table.number],
|
||||
# values=['validate', None],
|
||||
# where=invoice_table.id == invoice.id)
|
||||
# )
|
||||
# cursor.execute(*invoice_table.delete(
|
||||
# where=invoice_table.id == invoice.id)
|
||||
# )
|
||||
|
||||
# if sale.id:
|
||||
# cursor.execute(*sale_table.update(
|
||||
# columns=[sale_table.state, sale_table.shipment_state, sale_table.invoice_state],
|
||||
# values=['draft', 'none', 'none'],
|
||||
# where=sale_table.id == sale.id)
|
||||
# )
|
||||
# # The stock moves must be delete
|
||||
# stock_moves = [m.id for line in sale.lines for m in line.moves]
|
||||
# if stock_moves:
|
||||
# cursor.execute(*stock_move_table.update(
|
||||
# columns=[stock_move_table.state],
|
||||
# values=['draft'],
|
||||
# where=stock_move_table.id.in_(stock_moves)
|
||||
# ))
|
||||
|
||||
# cursor.execute(*stock_move_table.delete(
|
||||
# where=stock_move_table.id.in_(stock_moves))
|
||||
# )
|
||||
# return 'end'
|
||||
|
||||
# def unreconcile_move(self, move):
|
||||
# Reconciliation = Pool().get('account.move.reconciliation')
|
||||
# reconciliations = [l.reconciliation for l in move.lines if l.reconciliation]
|
||||
# if reconciliations:
|
||||
# Reconciliation.delete(reconciliations)
|
48
sale.xml
48
sale.xml
|
@ -1,48 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part of 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_view_form">
|
||||
<field name="model">sale.sale</field>
|
||||
<field name="inherit" ref="sale.sale_view_form"/>
|
||||
<field name="name">sale_form</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.action.wizard" id="act_sale_force_draft">
|
||||
<field name="name">Sale Force Draft</field>
|
||||
<field name="wiz_name">account_col.force_draft</field>
|
||||
</record>
|
||||
<record model="ir.action.keyword" id="action_sale_force_draft_keyword">
|
||||
<field name="keyword">form_action</field>
|
||||
<field name="model">sale.sale,-1</field>
|
||||
<field name="action" ref="act_sale_force_draft"/>
|
||||
</record> -->
|
||||
|
||||
<!-- <record model="ir.action.wizard" id="wizard_sale_voucher_advance">
|
||||
<field name="name">Voucher Advance</field>
|
||||
<field name="wiz_name">account_voucher.advance_voucher</field>
|
||||
<field name="model">sale.sale</field>
|
||||
</record>
|
||||
<record model="ir.action.keyword" id="act_sale_advance_keyword">
|
||||
<field name="keyword">form_action</field>
|
||||
<field name="model">sale.sale,-1</field>
|
||||
<field name="action" ref="wizard_sale_voucher_advance"/>
|
||||
</record> -->
|
||||
|
||||
<!-- <record model="ir.ui.view" id="sale_update_start_view_form">
|
||||
<field name="model">sale.update.start</field>
|
||||
<field name="type">form</field>
|
||||
<field name="name">sale_update_form</field>
|
||||
</record>
|
||||
<record model="ir.action.wizard" id="act_sale_update">
|
||||
<field name="name">Sale Update</field>
|
||||
<field name="wiz_name">sale.update</field>
|
||||
</record>
|
||||
<record model="ir.action.keyword" id="action_sale_update_keyword">
|
||||
<field name="keyword">form_action</field>
|
||||
<field name="model">sale.sale,-1</field>
|
||||
<field name="action" ref="act_sale_update"/>
|
||||
</record> -->
|
||||
</data>
|
||||
</tryton>
|
15
tax.py
15
tax.py
|
@ -9,7 +9,7 @@ from trytond.pyson import Eval
|
|||
from trytond.wizard import Wizard, StateView, Button, StateReport
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.report import Report
|
||||
|
||||
from trytond.exceptions import UserError
|
||||
|
||||
_ZERO = Decimal('0.0')
|
||||
|
||||
|
@ -61,18 +61,17 @@ class Tax(metaclass=PoolMeta):
|
|||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(Tax, cls).__setup__()
|
||||
cls.invoice_account.domain=[
|
||||
cls.invoice_account.domain = [
|
||||
('company', '=', Eval('company')),
|
||||
('type', '!=', None),
|
||||
('closed', '!=', True),
|
||||
]
|
||||
cls.credit_note_account.domain=[
|
||||
cls.credit_note_account.domain = [
|
||||
('company', '=', Eval('company')),
|
||||
('type', '!=', None),
|
||||
('closed', '!=', True),
|
||||
]
|
||||
|
||||
|
||||
def _process_tax(self, price_unit):
|
||||
res = super(Tax, self)._process_tax(price_unit)
|
||||
# Compute tax from taxable base
|
||||
|
@ -135,7 +134,8 @@ class TaxesByInvoiceStart(ModelView):
|
|||
class PrintTaxesByInvoice(Wizard):
|
||||
'Print Taxes By Invoice'
|
||||
__name__ = 'account_col.print_taxes_by_invoice'
|
||||
start = StateView('account_col.print_taxes_by_invoice.start',
|
||||
start = StateView(
|
||||
'account_col.print_taxes_by_invoice.start',
|
||||
'account_col.print_taxes_by_invoice_start_view_form', [
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Print', 'print_', 'tryton-print', default=True),
|
||||
|
@ -213,7 +213,7 @@ class TaxesPostedStart(ModelView):
|
|||
'Taxes Posted Start'
|
||||
__name__ = 'account_col.print_taxes_posted.start'
|
||||
fiscalyear = fields.Many2One('account.fiscalyear', 'Fiscal Year',
|
||||
required=True)
|
||||
required=True)
|
||||
start_period = fields.Many2One('account.period', 'Start Period',
|
||||
domain=[
|
||||
('fiscalyear', '=', Eval('fiscalyear')),
|
||||
|
@ -248,7 +248,8 @@ class TaxesPostedStart(ModelView):
|
|||
class PrintTaxesPosted(Wizard):
|
||||
'Print Taxes Posted'
|
||||
__name__ = 'account_col.print_taxes_posted'
|
||||
start = StateView('account_col.print_taxes_posted.start',
|
||||
start = StateView(
|
||||
'account_col.print_taxes_posted.start',
|
||||
'account_col.print_taxes_posted_start_view_form', [
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Print', 'print_', 'tryton-print', default=True),
|
||||
|
|
|
@ -24,7 +24,6 @@ xml:
|
|||
company.xml
|
||||
product.xml
|
||||
invoice_authorization.xml
|
||||
sale.xml
|
||||
payment_term.xml
|
||||
message.xml
|
||||
user.xml
|
||||
|
|
Loading…
Reference in New Issue