add changes in report portafolio status

This commit is contained in:
wilson gomez 2021-11-19 08:22:59 -05:00
parent 25de129702
commit 7077e395bb
9 changed files with 587 additions and 217 deletions

View File

@ -9,8 +9,9 @@ import configuration
def register():
Pool.register(
configuration.Configuration,
collection.Procedure,
collection.Level,
configuration.AccountProcedure,
configuration.Procedure,
configuration.Level,
collection.Tracking,
collection.Collection,
collection.CreateCollectionStart,

View File

@ -1,7 +1,7 @@
# 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 datetime import datetime, date
from trytond.model import Model, ModelView, ModelSQL, fields, sequence_ordered
from trytond.model import Model, ModelView, ModelSQL, fields
from trytond.pyson import If, Eval
from trytond.transaction import Transaction
from trytond.pool import Pool, PoolMeta
@ -27,52 +27,35 @@ _TYPES = [
]
class Procedure(ModelSQL, ModelView):
'Collection Procedure'
__name__ = 'collection.procedure'
name = fields.Char('Name', required=True, translate=True,
help="The main identifier of the Collection Procedure.")
levels = fields.One2Many('collection.level', 'procedure', 'Levels')
class Level(sequence_ordered(), ModelSQL, ModelView):
'Collection Level'
__name__ = 'collection.level'
procedure = fields.Many2One('collection.procedure', 'Procedure',
required=True, select=True)
name = fields.Char('Name')
collect_days = fields.Numeric('Days Collect')
def get_rec_name(self, name):
return self.name
def test(self, line, date):
if self.collect_days is not None:
return int((date - line.maturity_date).days) >= self.collect_days
class Tracking(ModelSQL, ModelView):
'Tracking'
__name__ = 'collection.tracking'
_rec_name = 'name'
collection = fields.Many2One('collection.collection', 'Collection',
required=True,)
required=True,)
date = fields.Date('Date')
user = fields.Many2One('res.user', 'User', readonly=True)
contact_method = fields.Selection(_TYPES, 'Contact Method', required=True,)
debt_to_day = fields.Numeric('Debt to Day', readonly=True, states={'readonly': Eval('state') != 'active', }, depends=_DEPENDS)
parcial_payment = fields.Function(fields.Boolean('Parcial Payment', readonly=True), 'get_parcial_payment')
compromise_payment_date = fields.Date('Compromise Payment Day', states={'readonly': Eval('state') != 'active', }, depends=_DEPENDS)
debt_to_day = fields.Numeric('Debt to Day', readonly=True, states={
'readonly': Eval('state') != 'active', }, depends=_DEPENDS)
parcial_payment = fields.Function(fields.Boolean(
'Parcial Payment', readonly=True), 'get_parcial_payment')
compromise_payment_date = fields.Date('Compromise Payment Day', states={
'readonly': Eval('state') != 'active', }, depends=_DEPENDS)
compromise_payment_amount = fields.Numeric('Compromise Payment',)
customer_comments = fields.Text('Comments', states={'readonly': Eval('state') != 'active',}, depends=_DEPENDS)
customer_comments = fields.Text(
'Comments', states={'readonly': Eval('state') != 'active', }, depends=_DEPENDS)
state = fields.Function(fields.Selection([
('done', 'Done'),
('active', 'Active'),
('inactive', "Inactive"),
], 'State', readonly=True), 'get_state', )
voucher_line = fields.Many2One('account.voucher.line', 'Voucher Line', readonly=True)
collection_amount = fields.Function(fields.Numeric('Collection Amount', readonly=True), 'get_collection_amount')
collection_percent = fields.Function(fields.Numeric('Collection Percent', digits=(2, 2), readonly=True), 'get_collection_percent')
voucher_line = fields.Many2One(
'account.voucher.line', 'Voucher Line', readonly=True)
collection_amount = fields.Function(fields.Numeric(
'Collection Amount', readonly=True), 'get_collection_amount')
collection_percent = fields.Function(fields.Numeric(
'Collection Percent', digits=(2, 2), readonly=True), 'get_collection_percent')
@classmethod
def __setup__(cls):
@ -127,7 +110,8 @@ class Tracking(ModelSQL, ModelView):
raise
if configuration:
_date = self.date + datetime.timedelta(days=configuration.tracking_days_expired)
_date = self.date + \
datetime.timedelta(days=configuration.tracking_days_expired)
if _date > Date.today():
return 'active'
# validate states please
@ -149,26 +133,27 @@ class Collection(ModelSQL, ModelView):
'Collection'
__name__ = 'collection.collection'
company = fields.Many2One('company.company', 'Company', required=True,
help="Make the collection belong to the company.",
select=True, domain=[
('id', If(Eval('context', {}).contains('company'), '=', '!='),
Eval('context', {}).get('company', -1)),
],
states=_STATES, depends=_DEPENDS)
help="Make the collection belong to the company.",
select=True, domain=[
('id', If(Eval('context', {}).contains('company'), '=', '!='),
Eval('context', {}).get('company', -1)),
],
states=_STATES, depends=_DEPENDS)
line = fields.Many2One('account.move.line', 'Move Line', required=True,
help="The receivable line to dun for.",
domain=[
('account.type.receivable', '=', 'true'),
('account.company', '=', Eval('company', -1)),
['OR',
('debit', '>', 0),
('credit', '<', 0),
],
],
states=_STATES, depends=_DEPENDS + ['company'])
help="The receivable line to dun for.",
domain=[
('account.type.receivable', '=', 'true'),
('account.company', '=', Eval('company', -1)),
['OR',
('debit', '>', 0),
('credit', '<', 0),
],
],
states=_STATES, depends=_DEPENDS + ['company'])
procedure = fields.Many2One('collection.procedure', 'Procedure',
states=_STATES, depends=_DEPENDS)
level = fields.Function(fields.Many2One('collection.level', 'Level', readonly=True),'get_level')
states=_STATES, depends=_DEPENDS)
level = fields.Function(fields.Many2One(
'collection.level', 'Level', readonly=True), 'get_level')
# level = fields.Many2One('collection.level', 'Level',
# domain=[
# ('procedure', '=', Eval('procedure', -1)),
@ -177,7 +162,7 @@ class Collection(ModelSQL, ModelView):
# blocked = fields.Boolean('Blocked',
# help="Check to block further levels of the procedure.")
active = fields.Function(fields.Boolean('Active'), 'get_active',
searcher='search_active')
searcher='search_active')
state = fields.Selection([
('running', "Running"),
@ -186,33 +171,36 @@ class Collection(ModelSQL, ModelView):
], 'State', readonly=True)
party = fields.Many2One('party.party', 'Party')
invoice = fields.Function(fields.Many2One('account.invoice', 'Invoice'),
'get_invoice')
'get_invoice')
amount = fields.Function(fields.Numeric('Amount Total',
digits=(16, Eval('currency_digits', 2)),
depends=['currency_digits']),
'get_amount')
digits=(
16, Eval('currency_digits', 2)),
depends=['currency_digits']),
'get_amount')
currency_digits = fields.Function(fields.Integer('Currency Digits'),
'get_line_field')
'get_line_field')
maturity_date = fields.Function(fields.Date('Maturity Date'),
'get_line_field', searcher='search_line_field')
'get_line_field', searcher='search_line_field')
expired_days = fields.Function(fields.Numeric('Expired Days'),
'get_expired_days')
'get_expired_days')
total_payment = fields.Function(fields.Numeric('Total Payment'),
'get_total_payment')
'get_total_payment')
pending_payment = fields.Function(fields.Numeric('Pending Payment'),
'get_pending_payment')
'get_pending_payment')
payments = fields.Function(fields.One2Many('account.move.line', None,
'Payments'), 'get_payments')
tracking = fields.One2Many('collection.tracking', 'collection', 'Tracking',)
'Payments'), 'get_payments')
tracking = fields.One2Many(
'collection.tracking', 'collection', 'Tracking',)
amount_second_currency = fields.Function(fields.Numeric(
'Amount Second Currency',
digits=(16, Eval('second_currency_digits', 2)),
depends=['second_currency_digits']), 'get_amount_second_currency')
second_currency = fields.Function(fields.Many2One('currency.currency',
'Second Currency'), 'get_second_currency')
'Second Currency'), 'get_second_currency')
second_currency_digits = fields.Function(fields.Integer(
'Second Currency Digits'), 'get_second_currency_digits')
collection_percent = fields.Function(fields.Numeric('Collection Percent', digits=(2, 2), readonly=True), 'get_collection_percent')
collection_percent = fields.Function(fields.Numeric(
'Collection Percent', digits=(2, 2), readonly=True), 'get_collection_percent')
@classmethod
def __setup__(cls):
@ -346,7 +334,7 @@ class Collection(ModelSQL, ModelView):
['OR',
('debit', '>', 0),
('credit', '<', 0),
],
],
('party', '!=', None),
('reconciliation', '=', None),
]
@ -394,9 +382,10 @@ class Collection(ModelSQL, ModelView):
lines = MoveLine.search(cls._overdue_line_domain(date))
line_ids = [l.id for l in lines]
lines_exist = cls.search([('line', 'in', line_ids),])
lines_exist = cls.search([('line', 'in', line_ids), ])
lines_exist = [l.line.id for l in lines_exist]
collections = (cls._get_collection(line, date) for line in lines if not line.id in lines_exist)
collections = (cls._get_collection(line, date)
for line in lines if not line.id in lines_exist)
cls.save([d for d in collections if d])
@classmethod
@ -427,7 +416,7 @@ class CreateCollectionStart(ModelView):
'Create Collection'
__name__ = 'collection.create.start'
date = fields.Date('Date', required=True,
help="Create Collection up to this date.")
help="Create Collection up to this date.")
@staticmethod
def default_date():
@ -439,10 +428,11 @@ class CreateCollection(Wizard):
'Create Collection'
__name__ = 'collection.create'
start = StateView('collection.create.start',
'collection.collection_create_start_view_form', [
Button('Cancel', 'end', 'tryton-cancel'),
Button('Create', 'create_', 'tryton-ok', default=True),
])
'collection.collection_create_start_view_form', [
Button('Cancel', 'end', 'tryton-cancel'),
Button('Create', 'create_',
'tryton-ok', default=True),
])
create_ = StateAction('collection.act_collection_form')
def do_create_(self, action):
@ -534,9 +524,11 @@ class Voucher(metaclass=PoolMeta):
if trackings:
index = len(trackings) - 1
if not trackings[index].voucher_line:
Tracking.write([trackings[index]], {'voucher_line': line.id})
Tracking.write([trackings[index]], {
'voucher_line': line.id})
if line.move_line.move_origin.state == 'paid' or line.move_line.move_origin.amount_to_pay == 0:
Collection.write([trackings[index].collection], {'state': 'done'})
Collection.write([trackings[index].collection], {
'state': 'done'})
class TrackingReportStart(ModelView):
@ -561,10 +553,10 @@ class TrackingReportWizard(Wizard):
'Tracking Report Wizard'
__name__ = 'collection.tracking_wizard'
start = StateView('collection.tracking_report.start',
'collection.tracking_start_view_form', [
Button('Cancel', 'end', 'tryton-cancel'),
Button('Print', 'print_', 'tryton-ok', default=True),
])
'collection.tracking_start_view_form', [
Button('Cancel', 'end', 'tryton-cancel'),
Button('Print', 'print_', 'tryton-ok', default=True),
])
print_ = StateReport('collection.tracking_report')
def do_print_(self, action):
@ -605,7 +597,8 @@ class TrackingReport(Report):
('collection.party.id', '=', data['party']),
)
trackings = Tracking.search(tracking_filtered, order=[('collection.party.name', 'ASC')])
trackings = Tracking.search(tracking_filtered, order=[
('collection.party.name', 'ASC')])
report_context['records'] = trackings
report_context['company'] = Company(data['company'])
@ -620,12 +613,37 @@ class PortfolioStatusStart(ModelView):
__name__ = 'collection.print_portfolio_status.start'
company = fields.Many2One('company.company', 'Company', required=True)
detailed = fields.Boolean('Detailed')
category_party = fields.Many2Many('party.category', None, None,
'Party Categories', domain=[('active', '=', True)])
date_to = fields.Date('Date to')
category_party = fields.MultiSelection('get_category_party', 'Party Categories')
kind = fields.Selection([
('in', 'Supplier'),
('out', 'Customer'),
], 'Kind', required=True)
payment_terms = fields.MultiSelection('get_payment_terms', 'Payment Term')
procedures = fields.MultiSelection('get_procedures', "Procedures")
# _get_types_cache = Cache('party.address.subdivision_type.get_types')
@classmethod
def get_procedures(cls):
pool = Pool()
Procedure = pool.get('collection.procedure')
procedures = Procedure.search_read([], fields_names=['id', 'name'])
return [(r['id'], r['name']) for r in procedures]
@classmethod
def get_category_party(cls):
pool = Pool()
PartyCategory = pool.get('party.category')
categories = PartyCategory.search_read([('active', '=', True)], fields_names=['id', 'name'])
return [(r['id'], r['name']) for r in categories]
@classmethod
def get_payment_terms(cls):
pool = Pool()
PaymentTerm = pool.get('account.invoice.payment_term')
payment_terms = PaymentTerm.search_read([], fields_names=['id', 'name'])
return [(r['id'], r['name']) for r in payment_terms]
@staticmethod
def default_company():
@ -641,20 +659,22 @@ class PortfolioStatus(Wizard):
__name__ = 'collection.print_portfolio_status'
start = StateView('collection.print_portfolio_status.start',
'collection.print_portfolio_status_start_view_form', [
Button('Cancel', 'end', 'tryton-cancel'),
Button('Print', 'print_', 'tryton-ok', default=True),
])
'collection.print_portfolio_status_start_view_form', [
Button('Cancel', 'end', 'tryton-cancel'),
Button('Print', 'print_', 'tryton-ok', default=True),
])
print_ = StateReport('collection.portfolio_status_report')
def do_print_(self, action):
data = {
'ids': [],
'company': self.start.company.id,
'detailed': self.start.detailed,
'kind': self.start.kind,
'category_party': [c.id for c in self.start.category_party],
'category_party': list(self.start.category_party),
'procedures': list(self.start.procedures),
'payment_terms': list(self.start.payment_terms),
'date_to': self.start.date_to,
}
return action, data
@ -670,11 +690,29 @@ class PortfolioStatusReport(Report):
def get_domain_invoice(cls, data):
domain = [
('company', '=', data['company']),
('state', '=', 'posted'),
('type', '=', data['kind']),
]
if data['category_party']:
domain.append(('party.categories', 'in', data['category_party']))
if data['payment_terms']:
domain.append(('payment_term', 'in', data['payment_terms']))
if data['date_to']:
to_date = data['date_to']
dt = datetime.combine(
date(to_date.year, to_date.month, to_date.day), datetime.min.time())
dom = [
'OR',
[
('payment_lines.date', '>=', data['date_to']),
# ('write_date', '>=', dt),
('state', '=', 'paid'),
],
('state', '=', 'posted')
]
domain.append(dom)
domain.append(('invoice_date', '<=', data['date_to']))
else:
domain.append(('state', '=', 'posted')),
return domain
@classmethod
@ -684,7 +722,17 @@ class PortfolioStatusReport(Report):
Company = pool.get('company.company')
Invoice = pool.get('account.invoice')
company = Company(data['company'])
dom_invoices = cls.get_domain_invoice(data)
if data['procedures']:
accounts = []
Procedure = pool.get('collection.procedure')
procedures = Procedure.search_read([
('id', 'in', data['procedures'])
], fields_names=['accounts'])
for procedure in procedures:
accounts.extend(list(procedure['accounts']))
dom_invoices.append(['account', 'in', accounts])
order = [('party.name', 'DESC'), ('invoice_date', 'ASC')]
invoices = Invoice.search(dom_invoices, order=order)
records = {}
@ -720,8 +768,42 @@ class PortfolioStatusReport(Report):
records[key_id].update(_expired_kind)
time_forward = 0
if invoice.estimate_pay_date:
time_forward = (today - invoice.estimate_pay_date).days
if data['date_to']:
maturity_date = None
move_lines_paid = []
pay_to_date = []
pay_append = pay_to_date.append
line_append = move_lines_paid.append
for line in invoice.payment_lines:
if line.move.date <= data['date_to']:
pay_append(line.debit - line.credit)
line_append(line.id)
else:
if line.maturity_date and line.maturity_date < maturity_date or maturity_date is None:
maturity_date = line.maturity_date
for line in invoice.move.lines:
line_id = line.id
if not line.reconciliation:
continue
for recline in line.reconciliation.lines:
if recline.id == line_id or line_id in move_lines_paid:
continue
if recline.move.date <= data['date_to']:
pay_append(recline.debit - recline.credit)
amount_paid = sum(pay_to_date)
if not maturity_date:
maturity_date = invoice.estimate_pay_date or invoice.invoice_date
time_forward = (data['date_to'] - maturity_date).days
amount = invoice.total_amount - amount_paid
else:
amount = invoice.amount_to_pay
if invoice.estimate_pay_date:
time_forward = (today - invoice.estimate_pay_date).days
if time_forward <= 0:
expire_time = 'range_0'
elif time_forward <= 30:
@ -738,7 +820,7 @@ class PortfolioStatusReport(Report):
notes = invoice.agent.rec_name
if notes and not records[key_id]['notes']:
records[key_id]['notes'] = notes
amount = invoice.amount_to_pay
records[key_id][expire_time].append(amount)
records[key_id]['invoice'].append(invoice)
records[key_id]['expired_days'] = time_forward
@ -750,13 +832,24 @@ class PortfolioStatusReport(Report):
if data['detailed']:
cond1 = 'where'
if data['category_party']:
cat_ids = str(tuple(data['category_party'])).replace(',', '') if len(data['category_party']) == 1 else str(tuple(data['category_party']))
cond1 = f'''join party_category_rel as pcr on pcr.party=pp.id where pcr.category in %s and''' % (cat_ids)
cat_ids = str(tuple(data['category_party'])).replace(',', '') if len(
data['category_party']) == 1 else str(tuple(data['category_party']))
cond1 = f'''join party_category_rel as pcr on pcr.party=pp.id where pcr.category in %s and''' % (
cat_ids)
cond2 = ''
if move_ids:
cond2 = 'and ml.id not in %s' % (str(tuple(move_ids)).replace(',', '') if len(move_ids) == 1 else str(tuple(move_ids)))
cond2 = 'and ml.id not in %s' % (str(tuple(move_ids)).replace(
',', '') if len(move_ids) == 1 else str(tuple(move_ids)))
cond3 = ''
if data['date_to']:
cond3 = ' and am.date <= %s' % (
data['date_to'].strftime("'%Y-%m-%d'"))
cond4 = ''
if data['procedures']:
cond4 = ' and ml.account in %s' % (str(tuple(accounts)).replace(
',', '') if len(accounts) == 1 else str(tuple(accounts)))
type_ = 'receivable'
if data['kind'] == 'in':
type_ = 'payable'
@ -787,8 +880,8 @@ class PortfolioStatusReport(Report):
on am.id=ml.move join party_party as pp
on pp.id=ml.party
%s at.{type_}='t' and ac.reconcile='t' and ml.maturity_date is not null and am.origin is null and ml.reconciliation is null
%s
group by ml.id, ml.move, pp.name, pp.id_number, ml.description, ml.reference, am.date, am.number, ml.maturity_date, ac.code, expired_days, ml.debit, ml.credit;""" % (cond1, cond2)
%s %s %s
group by ml.id, ml.move, pp.name, pp.id_number, ml.description, ml.reference, am.date, am.number, ml.maturity_date, ac.code, expired_days, ml.debit, ml.credit;""" % (cond1, cond2, cond3, cond4)
cursor.execute(query)
columns = list(cursor.description)
@ -828,10 +921,10 @@ class BillCollection(Wizard):
'Bill Collection'
__name__ = 'collection.print_bill_collection'
start = StateView('collection.print_bill_collection.start',
'collection.print_bill_collection_start_view_form', [
Button('Cancel', 'end', 'tryton-cancel'),
Button('Print', 'print_', 'tryton-ok', default=True),
])
'collection.print_bill_collection_start_view_form', [
Button('Cancel', 'end', 'tryton-cancel'),
Button('Print', 'print_', 'tryton-ok', default=True),
])
print_ = StateReport('collection.bill_collection_report')
def do_print_(self, action):
@ -885,10 +978,10 @@ class BillCollectionReport(Report):
('move_line', '!=', None),
('amount', '>', 0),
], fields_names=['amount', 'voucher.number', 'voucher.date',
'voucher.party.name', 'voucher.party.id_number',
'voucher.create_uid.name', 'move_line.maturity_date', 'move_line.debit',
'move_line.credit', 'move_line.move.origin.total_amount',
'move_line.move.origin.number', 'move_line.description']
'voucher.party.name', 'voucher.party.id_number',
'voucher.create_uid.name', 'move_line.maturity_date', 'move_line.debit',
'move_line.credit', 'move_line.move.origin.total_amount',
'move_line.move.origin.number', 'move_line.description']
)
move_lines = []
sum_total = []
@ -899,7 +992,7 @@ class BillCollectionReport(Report):
try:
rate = value['amount'] / value['total_amount']
value['rate'] = rate
except :
except:
pass
move_lines_append(value)
add_sum_total(value['amount'])

View File

@ -47,110 +47,6 @@ this repository contains the full copyright notices and license terms. -->
<field name="group" ref="group_collection"/>
</record>
<record model="ir.ui.view" id="collection_procedure_view_form">
<field name="model">collection.procedure</field>
<field name="type">form</field>
<field name="name">collection_procedure_form</field>
</record>
<record model="ir.ui.view" id="collection_procedure_view_list">
<field name="model">collection.procedure</field>
<field name="type">tree</field>
<field name="name">collection_procedure_list</field>
</record>
<record model="ir.action.act_window" id="act_collection_procedure_form">
<field name="name">Collection Procedures</field>
<field name="res_model">collection.procedure</field>
</record>
<record model="ir.action.act_window.view"
id="act_collection_procedure_form_view1">
<field name="sequence" eval="10"/>
<field name="view" ref="collection_procedure_view_list"/>
<field name="act_window" ref="act_collection_procedure_form"/>
</record>
<record model="ir.action.act_window.view"
id="act_collection_procedure_form_view2">
<field name="sequence" eval="20"/>
<field name="view" ref="collection_procedure_view_form"/>
<field name="act_window" ref="act_collection_procedure_form"/>
</record>
<menuitem parent="menu_collection_configuration" sequence="10"
action="act_collection_procedure_form"
id="menu_collection_procedure_form"/>
<!-- <record model="ir.model.access"
id="access_collection_procedure">
<field name="model" search="[('model', '=', 'collection.procedure')]"/>
<field name="perm_read" eval="False"/>
<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_collection_procedure_account_admin">
<field name="model" search="[('model', '=', 'collection.procedure')]"/>
<field name="group" ref="group_collection_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> -->
<!-- <record model="ir.model.access"
id="access_collection_procedure_collection">
<field name="model" search="[('model', '=', 'collection.procedure')]"/>
<field name="group" ref="group_collection"/>
<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.ui.view" id="collection_level_view_form">
<field name="model">collection.level</field>
<field name="type">form</field>
<field name="name">collection_level_form</field>
</record>
<record model="ir.ui.view" id="collection_level_view_list">
<field name="model">collection.level</field>
<field name="type">tree</field>
<field name="priority" eval="10"/>
<field name="name">collection_level_list</field>
</record>
<record model="ir.ui.view" id="collection_level_view_list_sequence">
<field name="model">collection.level</field>
<field name="type">tree</field>
<field name="priority" eval="20"/>
<field name="name">collection_level_list_sequence</field>
</record>
<!-- <record model="ir.model.access" id="access_collection_level">
<field name="model" search="[('model', '=', 'collection.level')]"/>
<field name="perm_read" eval="False"/>
<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_collection_level_account_admin">
<field name="model" search="[('model', '=', 'collection.level')]"/>
<field name="group" ref="group_collection_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> -->
<!-- <record model="ir.model.access"
id="access_collection_level_collection">
<field name="model" search="[('model', '=', 'collection.level')]"/>
<field name="group" ref="group_collection"/>
<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.ui.view" id="collection_view_form">
<field name="model">collection.collection</field>
<field name="type">form</field>

View File

@ -1,6 +1,7 @@
# 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.model import ModelView, ModelSQL, fields, sequence_ordered
from trytond.pyson import Eval
class Configuration(ModelSQL, ModelView):
@ -9,3 +10,42 @@ class Configuration(ModelSQL, ModelView):
tracking_days_expired = fields.Integer('Days to Expired of Tracking',
required=True)
company = fields.Many2One('company.company', 'Company', required=True)
class AccountProcedure(ModelSQL):
'Account Procedure'
__name__ = 'account.account.procedure'
account = fields.Many2One('account.account', 'Account',
ondelete='CASCADE', select=True, required=True)
procedure = fields.Many2One('collection.procedure', 'Procedure', ondelete='CASCADE', select=True, required=True)
class Procedure(ModelSQL, ModelView):
'Collection Procedure'
__name__ = 'collection.procedure'
name = fields.Char('Name', required=True, translate=True,
help="The main identifier of the Collection Procedure.")
levels = fields.One2Many('collection.level', 'procedure', 'Levels')
accounts = fields.Many2Many('account.account.procedure', 'procedure',
'account', 'Account', domain=[
('closed', '!=', True),
('type', '!=', None),
('company', '=', Eval('context', {}).get('company', -1)),
])
class Level(sequence_ordered(), ModelSQL, ModelView):
'Collection Level'
__name__ = 'collection.level'
procedure = fields.Many2One('collection.procedure', 'Procedure',
required=True, select=True)
name = fields.Char('Name')
collect_days = fields.Numeric('Days Collect')
def get_rec_name(self, name):
return self.name
def test(self, line, date):
if self.collect_days is not None:
return int((date - line.maturity_date).days) >= self.collect_days

View File

@ -33,5 +33,108 @@ this repository contains the full copyright notices and license terms. -->
action="act_collection_configuration_form" sequence="10"
id="menu_configuration" icon="tryton-list"/>
<record model="ir.ui.view" id="collection_level_view_form">
<field name="model">collection.level</field>
<field name="type">form</field>
<field name="name">collection_level_form</field>
</record>
<record model="ir.ui.view" id="collection_level_view_list">
<field name="model">collection.level</field>
<field name="type">tree</field>
<field name="priority" eval="10"/>
<field name="name">collection_level_list</field>
</record>
<record model="ir.ui.view" id="collection_level_view_list_sequence">
<field name="model">collection.level</field>
<field name="type">tree</field>
<field name="priority" eval="20"/>
<field name="name">collection_level_list_sequence</field>
</record>
<!-- <record model="ir.model.access" id="access_collection_level">
<field name="model" search="[('model', '=', 'collection.level')]"/>
<field name="perm_read" eval="False"/>
<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_collection_level_account_admin">
<field name="model" search="[('model', '=', 'collection.level')]"/>
<field name="group" ref="group_collection_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> -->
<!-- <record model="ir.model.access"
id="access_collection_level_collection">
<field name="model" search="[('model', '=', 'collection.level')]"/>
<field name="group" ref="group_collection"/>
<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.ui.view" id="collection_procedure_view_form">
<field name="model">collection.procedure</field>
<field name="type">form</field>
<field name="name">collection_procedure_form</field>
</record>
<record model="ir.ui.view" id="collection_procedure_view_list">
<field name="model">collection.procedure</field>
<field name="type">tree</field>
<field name="name">collection_procedure_list</field>
</record>
<record model="ir.action.act_window" id="act_collection_procedure_form">
<field name="name">Collection Procedures</field>
<field name="res_model">collection.procedure</field>
</record>
<record model="ir.action.act_window.view"
id="act_collection_procedure_form_view1">
<field name="sequence" eval="10"/>
<field name="view" ref="collection_procedure_view_list"/>
<field name="act_window" ref="act_collection_procedure_form"/>
</record>
<record model="ir.action.act_window.view"
id="act_collection_procedure_form_view2">
<field name="sequence" eval="20"/>
<field name="view" ref="collection_procedure_view_form"/>
<field name="act_window" ref="act_collection_procedure_form"/>
</record>
<menuitem parent="menu_collection_configuration" sequence="10"
action="act_collection_procedure_form"
id="menu_collection_procedure_form"/>
<!-- <record model="ir.model.access"
id="access_collection_procedure">
<field name="model" search="[('model', '=', 'collection.procedure')]"/>
<field name="perm_read" eval="False"/>
<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_collection_procedure_account_admin">
<field name="model" search="[('model', '=', 'collection.procedure')]"/>
<field name="group" ref="group_collection_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> -->
<!-- <record model="ir.model.access"
id="access_collection_procedure_collection">
<field name="model" search="[('model', '=', 'collection.procedure')]"/>
<field name="group" ref="group_collection"/>
<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> -->
</data>
</tryton>

View File

@ -2,6 +2,14 @@
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:account.account.procedure,account:"
msgid "Account"
msgstr "Cuentas"
msgctxt "field:account.account.procedure,procedure:"
msgid "Procedure"
msgstr "Procedimiento de Cartera"
msgctxt "field:collection.collection,active:"
msgid "Active"
msgstr "Activo"
@ -126,10 +134,30 @@ msgctxt "field:collection.print_portfolio_status.start,company:"
msgid "Company"
msgstr "Empresa"
msgctxt "field:collection.print_portfolio_status.start,date_to:"
msgid "Date to"
msgstr "Fecha corte"
msgctxt "field:collection.print_portfolio_status.start,detailed:"
msgid "Detailed"
msgstr "Detallado"
msgctxt "field:collection.print_portfolio_status.start,kind:"
msgid "Kind"
msgstr "Tipo"
msgctxt "field:collection.print_portfolio_status.start,payment_terms:"
msgid "Payment Term"
msgstr "Plazo de pago"
msgctxt "field:collection.print_portfolio_status.start,procedures:"
msgid "Procedures"
msgstr "Procedimiento de Cartera"
msgctxt "field:collection.procedure,accounts:"
msgid "Account"
msgstr "Cuentas"
msgctxt "field:collection.procedure,levels:"
msgid "Levels"
msgstr "Nivel de Cartera"
@ -220,6 +248,10 @@ msgstr "Crear Cartera a esta Fecha"
msgctxt "help:collection.procedure,name:"
msgid "The main identifier of the Collection Procedure."
msgstr "Identificacion de cartera"
msgctxt "model:account.account.procedure,name:"
msgid "Account Procedure"
msgstr ""
msgctxt "model:collection.collection,name:"
@ -308,7 +340,6 @@ msgctxt ""
msgid "Running"
msgstr "En ejecución"
#, fuzzy
msgctxt "model:ir.rule.group,name:rule_group_collection"
msgid "Collection"
msgstr "Cartera"
@ -357,6 +388,189 @@ msgctxt "model:res.group,name:group_collection"
msgid "Collection"
msgstr "Cartera"
#, fuzzy
msgctxt "report:collection.tracking_report:"
msgid "$"
msgstr "$"
#, fuzzy
msgctxt "report:collection.tracking_report:"
msgid "("
msgstr "("
msgctxt "report:collection.tracking_report:"
msgid "($"
msgstr ""
msgctxt "report:collection.tracking_report:"
msgid "(line.debt_to_day - line.collection_amount)"
msgstr ""
#, fuzzy
msgctxt "report:collection.tracking_report:"
msgid ")"
msgstr ")"
#, fuzzy
msgctxt "report:collection.tracking_report:"
msgid ","
msgstr ","
#, fuzzy
msgctxt "report:collection.tracking_report:"
msgid "-"
msgstr "-"
msgctxt "report:collection.tracking_report:"
msgid "- pta"
msgstr ""
msgctxt "report:collection.tracking_report:"
msgid "--"
msgstr ""
msgctxt "report:collection.tracking_report:"
msgid "--)"
msgstr ""
#, fuzzy
msgctxt "report:collection.tracking_report:"
msgid "/"
msgstr "/"
msgctxt "report:collection.tracking_report:"
msgid "/for"
msgstr ""
msgctxt "report:collection.tracking_report:"
msgid "00/00/0000"
msgstr ""
msgctxt "report:collection.tracking_report:"
msgid "00:00:00"
msgstr ""
#, fuzzy
msgctxt "report:collection.tracking_report:"
msgid ":"
msgstr ":"
msgctxt "report:collection.tracking_report:"
msgid "???"
msgstr ""
msgctxt "report:collection.tracking_report:"
msgid "COMPROMISO RECAUDO"
msgstr ""
msgctxt "report:collection.tracking_report:"
msgid "DEUDA"
msgstr ""
msgctxt "report:collection.tracking_report:"
msgid "DOC"
msgstr ""
msgctxt "report:collection.tracking_report:"
msgid "ESTADO FACTURA"
msgstr ""
msgctxt "report:collection.tracking_report:"
msgid "FECHA"
msgstr ""
msgctxt "report:collection.tracking_report:"
msgid "FECHA FINAL:"
msgstr ""
msgctxt "report:collection.tracking_report:"
msgid "FECHA INICIAL:"
msgstr ""
msgctxt "report:collection.tracking_report:"
msgid "Page"
msgstr ""
msgctxt "report:collection.tracking_report:"
msgid "SALDO"
msgstr ""
msgctxt "report:collection.tracking_report:"
msgid "SEGUIMIENTO DE CARTERA"
msgstr ""
msgctxt "report:collection.tracking_report:"
msgid "TERCERO"
msgstr ""
msgctxt "report:collection.tracking_report:"
msgid "TOTAL FACTURA"
msgstr ""
msgctxt "report:collection.tracking_report:"
msgid "VALOR RECAUDADO"
msgstr ""
msgctxt "report:collection.tracking_report:"
msgid "company.party.name"
msgstr ""
msgctxt "report:collection.tracking_report:"
msgid "de"
msgstr ""
msgctxt "report:collection.tracking_report:"
msgid "end"
msgstr ""
msgctxt "report:collection.tracking_report:"
msgid "for each='line in records'"
msgstr ""
msgctxt "report:collection.tracking_report:"
msgid "line.collection.amount"
msgstr ""
msgctxt "report:collection.tracking_report:"
msgid "line.collection.invoice.number"
msgstr ""
msgctxt "report:collection.tracking_report:"
msgid "line.collection.invoice.state_string"
msgstr ""
msgctxt "report:collection.tracking_report:"
msgid "line.collection.party.name"
msgstr ""
msgctxt "report:collection.tracking_report:"
msgid "line.collection_amount"
msgstr ""
msgctxt "report:collection.tracking_report:"
msgid "line.compromise_payment_amount"
msgstr ""
msgctxt "report:collection.tracking_report:"
msgid "line.date"
msgstr ""
msgctxt "report:collection.tracking_report:"
msgid "line.debt_to_day"
msgstr ""
msgctxt "report:collection.tracking_report:"
msgid "pta"
msgstr ""
msgctxt "report:collection.tracking_report:"
msgid "start"
msgstr ""
msgctxt "report:collection.tracking_report:"
msgid "€"
msgstr ""
msgctxt "selection:collection.collection,state:"
msgid "Cancel"
msgstr "Cancelar"
@ -369,6 +583,15 @@ msgctxt "selection:collection.collection,state:"
msgid "Running"
msgstr "En ejecución"
#, fuzzy
msgctxt "selection:collection.print_portfolio_status.start,kind:"
msgid "Customer"
msgstr "Cliente"
msgctxt "selection:collection.print_portfolio_status.start,kind:"
msgid "Supplier"
msgstr "Proveedor"
msgctxt "selection:collection.tracking,contact_method:"
msgid "E-Mail"
msgstr "Correo electrónico"
@ -433,6 +656,10 @@ msgctxt "view:collection.create.start:"
msgid "Create Dunning for date"
msgstr "Crear Cartera Para la Fecha"
msgctxt "view:collection.print_portfolio_status.start:"
msgid "Procedures"
msgstr "Procedimiento de cartera"
msgctxt "view:collection.tracking:"
msgid "Collection Percent (%)"
msgstr "Porcentaje de Recaudo"

Binary file not shown.

View File

@ -4,6 +4,7 @@ this repository contains the full copyright notices and license terms. -->
<form>
<label name="name"/>
<field name="name"/>
<field name="accounts" colspan="4"/>
<field name="levels" colspan="4"
view_ids="collection.collection_level_view_list_sequence"/>
</form>

View File

@ -6,8 +6,17 @@ this repository contains the full copyright notices and license terms. -->
<field name="company" widget="selection"/>
<label name="detailed"/>
<field name="detailed"/>
<label name="date_to"/>
<field name="date_to"/>
<label name="kind"/>
<field name="kind"/>
<newline />
<field name="category_party" colspan="4"/>
<group colspan="2" string="Procedures">
<field name="procedures"/>
</group>
<newline/>
<label name="category_party" colspan="2" xalign="0"/>
<label name="payment_terms" colspan="2" xalign="0"/>
<field name="category_party" colspan="2"/>
<field name="payment_terms" colspan="2"/>
</form>