Skip to content

Commit

Permalink
update sale_report_ru
Browse files Browse the repository at this point in the history
  • Loading branch information
yelizariev committed Apr 3, 2014
1 parent a983e0d commit d850dca
Show file tree
Hide file tree
Showing 4 changed files with 234 additions and 103 deletions.
15 changes: 13 additions & 2 deletions sale_report_ru/__openerp__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
{
"name" : "Sale contract ",
"name" : "Sale reports in russian ",
"version" : "0.1",
"author" : "Ivan Yelizariev",
"category" : "Sale",
"website" : "https://it-projects.info",
"description": """
depends on https://github.com/j2a/pytils
Добавляет печатные формы:
* договор продаж
* акт приема-передачи
* счет (заменяет встроенный отчет)
* предложение (заменяет встроенный отчет)
""",
"depends" : ["sale", "res_partner_ru"],
"depends" : ["sale", "account", "res_partner_ru"],
"data":[
'report.xml',
'views.xml',
Expand Down
59 changes: 50 additions & 9 deletions sale_report_ru/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,67 @@

class res_partner(osv.Model):
_inherit = "res.partner"
def _get_default_bank_id(self, cr, uid, ids, field_name, arg, context=None):
res = {}
for row in self.browse(cr, uid, ids, context):
res[row.id] = self.bank_ids && self.bank_ids[0]
return res

_columns = {
'represented_by':fields.char('Represented by', size=256, help='String for contracts'),
'default_bank_id':fields.function(_get_default_bank_id, type='many2one')
}

def _get_amount_in_words(self, cr, uid, ids, field_name, arg, context=None):
res = {}

for row in self.browse(cr, uid, ids, context):
rubles = numeral.rubles(int(row.amount_total))
copek_num = round(row.amount_total - int(row.amount_total))
copek = numeral.choose_plural(int(copek_num), (u"копейка", u"копейки", u"копеек"))
res[row.id] = ("%s %02d %s")%(rubles, copek_num, copek)

return res

class sale_order(osv.Model):
_inherit = 'sale.order'

def _get_amount_in_words(self, cr, uid, ids, field_name, arg, context):
res = {}
_columns = {
'amount_total_in_words': fields.function(_get_amount_in_words, string='Amount in words', type='char'),

for row in self.browse(cr, uid, ids, context):
rubles = numeral.rubles(int(row.amount_total))
copek_num = round(row.amount_total - int(row.amount_total))
copek = numeral.choose_plural(int(copek_num), (u"копейка", u"копейки", u"копеек"))
res[row.id] = ("%s %02d %s")%(rubles, copek_num, copek)
}
def _prepare_invoice(self, cr, uid, order, lines, context=None):
invoice_vals = super(sale_order, self)._prepare_invoice(self, cr, uid, order, lines, context)
invoice_vals['date_origin'] = order.date_order

return res
class account_invoice(osv.Model):
_inherit = 'account.invoice'

def _get_partner_bank_id(self, cr, uid, context=None):
company_id = self.pool.get('res.company')._company_default_get(cr, uid, 'account.invoice', context=context)
if not company_id:
return None
return company_id.partner_id.default_bank_id

_columns = {
'amount_total_in_words': fields.function(_get_amount_in_words, string='Amount in words', type='char'),

'date_origin': fields.date('Origin date', required=False, readonly=True),
}
_defaults = {
'partner_bank_id': _get_partner_bank_id,
}

#class account_invoice_line(osv.Model):
# _inherit = 'account.invoice.line'
# def _get_synonym(self, cr, uid, ids, field_name, arg, context):
# res = {}
# for row in self.browse(cr, uid, ids, context):
# res[row.id] = {}
# res[row.id]['product_uom_qty'] = row.quantity
# res[row.id]['product_uom'] = row.uos_id
# return res
#
# _columns = {
# 'product_uom_qty':fields.function(_get_synonym, multi='synonym', type='float'),
# 'product_uom':fields.function(_get_synonym, multi='synonym', type='many2one'),
# }
Loading

0 comments on commit d850dca

Please sign in to comment.