Esempio n. 1
0
 def _check_partner(self):
     if (self.session_id.config_id.require_customer == 'order' and
             not self.partner_id):
         raise exceptions.ValidationError(
             _('Customer is required for this order and is missing.'))
Esempio n. 2
0
 def button_cancel(self):
     for rec in self:
         for line in rec.transaction_ids:
             if line.fondo_rotario:
                 raise exceptions.ValidationError(u'No puede cancelar una caja con registros incluidos en un 3 en 1.')
     return super(GrpCajaChicaTesoreria, self).button_cancel()
    def create_invoices(self, cr, uid, ids, context=None):
        """ create invoices for the active sales orders """
        sale_obj = self.pool.get('sale.order')
        act_window = self.pool.get('ir.actions.act_window')
        wizard = self.browse(cr, uid, ids[0], context)
        sale_ids = context.get('active_ids', [])
        invoice_obj = self.pool.get('account.invoice')

        if wizard.advance_payment_method == 'multiple':
            sale = sale_obj.browse(cr, uid, sale_ids, context=context)[0]
            if sale.cuota_ids:
                for cuota in sale.cuota_ids:
                    if cuota.invoice_id:
                        raise exceptions.ValidationError(
                            "Cuotas ya facturadas")
                tax = sale.order_line[0].tax_id.amount
                c_monto = round(sum(c.monto_cuota for c in sale.cuota_ids), 6)
                amount_untaxed = round(sale.amount_untaxed, 6)
                if c_monto != amount_untaxed:
                    raise exceptions.ValidationError(
                        "El monto total del contrato no coincide con al suma de las cuotas"
                    )
                nro_cuota = 0
                for cuota in sale.cuota_ids:
                    datos = {
                        'amount_untaxed':
                        cuota.monto_cuota,
                        'date_invoice':
                        cuota.fecha_creacion,
                        'date_due':
                        cuota.fecha_vencimiento,
                        'origin':
                        cuota.sale_id.name,
                        'type':
                        'out_invoice',
                        'reference':
                        False,
                        'account_id':
                        cuota.sale_id.partner_id.
                        property_account_receivable_id.id,
                        'partner_id':
                        cuota.sale_id.partner_invoice_id.id,
                        'currency_id':
                        cuota.sale_id.pricelist_id.currency_id.id,
                        'comment':
                        '',
                        'payment_term_id':
                        cuota.sale_id.payment_term_id.id,
                        'fiscal_position_id':
                        cuota.sale_id.fiscal_position_id.id or cuota.sale_id.
                        partner_id.property_account_position_id.id,
                        #'section_id': cuota.sale_id.team_id.id,
                    }
                    datos = self._prepare_advance_invoice_vals2(
                        cr, uid, ids, datos, context=context)
                    # si es la ultima cuota
                    nro_cuota += 1
                    nro_cuotas = len(sale.cuota_ids)

                    invoice_id = self._create_invoices(cr,
                                                       uid,
                                                       datos,
                                                       sale_ids[0],
                                                       context=context)
                    #invoice_id = super(self, sale_advance_payment_inv).create_invoices(cr, uid, datos, sale_ids[0], context=context)
                    #invoice_obj.write(cr, uid, invoice_id, datos, context=context)

                    cuota_obj = self.pool.get('sale.order.line.cuota')
                    cuota_obj.write(cr,
                                    uid,
                                    cuota.id, {'invoice_id': invoice_id},
                                    context=context)

                    monto_cuota = cuota.monto_cuota
                    data_il = {
                        'origin': cuota.sale_id.name,
                        'tax_id': cuota.order_line_id.tax_id.id,
                        'invoice_id': invoice_id,
                        'price_unit': round(float(monto_cuota), 6),
                        'quantity': 1,
                        'more_description': "%s" % cuota.description
                    }
                    sale_order_line_ids = cuota.order_line_id
                    self.generate_invoice_lines(cr, uid, sale_order_line_ids,
                                                data_il, context)
                    invoice = invoice_obj.browse(cr, uid, invoice_id, context)
                    #invoice_obj.button_reset_taxes(cr, uid, invoice_id, context)
                    #invoice.button_reset_taxes()

                    if nro_cuota == nro_cuotas:
                        #sale_obj.write(cr, uid, [sale.id], {'state': 'progress'})
                        if context.get('open_invoices', False):
                            return sale_obj.action_view_invoice(
                                cr, uid, sale_ids, context=context)
                        return {'type': 'ir.actions.act_window_close'}

            else:
                raise exceptions.ValidationError(
                    u"Debe de crear cuotas para esta opción")
            if context.get('open_invoices', False):
                return sale_obj.action_view_invoice(cr,
                                                    uid,
                                                    sale_ids,
                                                    context=context)
            return {'type': 'ir.actions.act_window_close'}

        if wizard.advance_payment_method == 'all':
            for sale_id in sale_ids:
                sale_order = self.pool.get('sale.order').browse(
                    cr, uid, sale_id)
                for line in sale_order.order_line:
                    if line.cuota_ids:
                        raise exceptions.ValidationError(
                            "Orden tiene cuotas.\nSe debe seleccionar la opción 'Hacer varias facturas'"
                        )

            res = sale_obj.manual_invoice(cr, uid, sale_ids, context)

            if context.get('open_invoices', False):
                return res
            return {'type': 'ir.actions.act_window_close'}

        if wizard.advance_payment_method in ['percentage', 'fixed']:
            for sale_id in sale_ids:
                sale_order = self.pool.get('sale.order').browse(
                    cr, uid, sale_id)
                for line in sale_order.order_line:
                    if line.cuota_ids:
                        raise exceptions.ValidationError(
                            "Orden tiene cuotas.\nSe debe seleccionar la opción 'Hacer varias facturas'"
                        )

        if wizard.advance_payment_method == 'lines':
            for sale_id in sale_ids:
                sale_order = self.pool.get('sale.order').browse(
                    cr, uid, sale_id)
                for line in sale_order.order_line:
                    if line.cuota_ids:
                        raise exceptions.ValidationError(
                            "Orden tiene cuotas.\nSe debe seleccionar la opción 'Hacer varias facturas'"
                        )
        # open the list view of sales order lines to invoice
            res = act_window.for_xml_id(cr, uid, 'sale',
                                        'action_order_line_tree2', context)
            res['context'] = {
                'search_default_uninvoiced': 1,
                'search_default_order_id': sale_ids and sale_ids[0] or False,
            }
            return res
        assert wizard.advance_payment_method in ('fixed', 'percentage')

        inv_ids = []
        for sale_id, inv_values in self._prepare_advance_invoice_vals(
                cr, uid, ids, context=context):
            inv_ids.append(
                self._create_invoices(cr,
                                      uid,
                                      inv_values,
                                      sale_id,
                                      context=context))
            #inv_ids.append(super(self, sale_advance_payment_inv)._create_invoices(cr, uid, inv_values, sale_id, context=context))

        if context.get('open_invoices', False):
            return self.open_invoices(cr, uid, ids, inv_ids, context=context)
        return {'type': 'ir.actions.act_window_close'}
Esempio n. 4
0
 def _check_krs(self):
     self._clean_field_value('krs')
     if self.krs and (len(self.krs) != 10 or not self.krs.isdigit()):
         raise exceptions.ValidationError("Niepoprawny KRS.")
    def crear_recibo(self):
        if self.solicitud_anticipos_id:
            account_voucher_obj = self.env['account.voucher']
            partner = self.employee_id.address_home_id
            if self.diferencia > 0:
                if self.journal_id and self.journal_id.type == 'purchase':
                    journal_id = self.journal_id
                else:
                    search_args = [('type', '=', 'purchase')]
                    if self.env.user.company_id.currency_id.id != self.currency_id.id:
                        search_args.append(
                            ('currency', '=', self.currency_id.id))
                    else:
                        search_args.extend([
                            '|', ('currency', '=', False),
                            ('currency', '=',
                             self.env.user.company_id.currency_id.id)
                        ])
                    journal_id = self.env['account.journal'].search(
                        search_args, limit=1)
                if journal_id:
                    account_id = partner.property_account_payable
                    if not account_id:
                        account_id = journal_id.default_credit_account_id
                        if not account_id:
                            raise exceptions.ValidationError(
                                _(u'Error, debe configurar la cuenta a pagar'
                                  u' del beneficierio o del diario contable utilizado.'
                                  ))

                    sa_line_id = len(
                        self.solicitud_anticipos_id.line_ids
                    ) and self.solicitud_anticipos_id.line_ids[0] or False
                    account_voucher_id = account_voucher_obj.create({
                        'partner_id':
                        partner.id or False,
                        'date':
                        fields.date.today(),
                        'journal_id':
                        journal_id.id,
                        'type':
                        'payment',
                        'account_id':
                        account_id.id,
                        'amount':
                        abs(self.diferencia),
                        'payment_rate':
                        0,
                        'operating_unit_id':
                        self.solicitud_anticipos_id.operating_unit_id.id,
                        'solicitud_anticipos_id':
                        self.solicitud_anticipos_id.id,
                        'rendicion_anticipos_id':
                        self.id,
                        'line_dr_ids': [(0, 0, {
                            'concept_id':
                            sa_line_id and sa_line_id.concept_id.id or False,
                            'account_id':
                            sa_line_id and sa_line_id.account_id.id or False,
                            'amount_unreconciled':
                            abs(self.diferencia),
                            'amount':
                            abs(self.diferencia),
                            'journal_id':
                            journal_id.id or False,
                            'partner_id':
                            partner.id or False,
                        })]
                    })

                    tipo_ejecucion = self.env['tipo.ejecucion.siif'].search([
                        ('codigo', '=', 'P')
                    ])
                    invoice_id = self.env['account.invoice'].create({
                        'partner_id':
                        account_voucher_id.partner_id.id,
                        'account_id':
                        account_voucher_id.account_id.id,
                        'date_invoice':
                        account_voucher_id.date,
                        'internal_number':
                        account_voucher_id.number,
                        'number':
                        account_voucher_id.number,
                        'currency_id':
                        account_voucher_id.currency_id.id,
                        'siif_tipo_ejecucion':
                        tipo_ejecucion and tipo_ejecucion.id or False,
                        'type':
                        'in_invoice',
                        'amount_total':
                        abs(self.diferencia),
                        'pago_aprobado':
                        False,
                        'doc_type':
                        'vales_caja',
                        'state':
                        'open',
                        'invoice_line': [(0, 0, {
                            'name': line.name or '',
                            'account_id': line.account_id.id,
                            'price_unit': line.amount
                        }) for line in account_voucher_id.line_dr_ids]
                    })
                    account_voucher_id.write({'invoice_id': invoice_id.id})
                    invoice_id.write({'doc_type': 'vales_caja'})
                else:
                    raise exceptions.ValidationError(
                        _(u'Error, debe seleccionar un diario compra'
                          u' o configurar un diario de compra de la compañia.')
                    )
            else:
                if self.journal_id and self.journal_id.type == 'sale':
                    journal_id = self.journal_id
                else:
                    search_args = [('type', '=', 'sale')]
                    if self.env.user.company_id.currency_id.id != self.currency_id.id:
                        search_args.append(
                            ('currency', '=', self.currency_id.id))
                    else:
                        search_args.extend([
                            '|', ('currency', '=', False),
                            ('currency', '=',
                             self.env.user.company_id.currency_id.id)
                        ])
                    journal_id = self.env['account.journal'].search(
                        search_args, limit=1)
                if journal_id:
                    account_id = partner.property_account_receivable
                    if not account_id:
                        account_id = journal_id.default_debit_account_id
                        if not account_id:
                            raise exceptions.ValidationError(
                                _(u'Error, debe configurar la cuenta a cobrar'
                                  u' del beneficierio o del diario contable utilizado.'
                                  ))
                    # product_id = self.solicitud_anticipos_id and self.sudo().operating_unit_id.anticipo_product_id
                    product_id = self.get_anticipo_product()
                    if not product_id:
                        raise ValidationError(
                            _(u"Debe configurar un producto Dev. Anticipos para la Unidad ejecutora seleccionada!"
                              ))
                        # raise ValidationError(_(u"Debe configurar un producto con la opción 'Devolución de anticipos' seleccionada!"))
                    account_voucher_id = account_voucher_obj.create({
                        'partner_id':
                        partner.id or False,
                        'date':
                        fields.date.today(),
                        'journal_id':
                        journal_id.id,
                        'type':
                        'sale',
                        'account_id':
                        account_id.id,
                        'amount':
                        abs(self.diferencia),
                        'payment_rate':
                        0,
                        'operating_unit_id':
                        self.solicitud_anticipos_id.operating_unit_id.id,
                        'rendicion_anticipos_id':
                        self.id,
                        'solicitud_anticipos_id':
                        self.solicitud_anticipos_id.id,
                        'line_cr_ids': [(0, 0, {
                            'account_id':
                            partner.customer_advance_account_id.id,
                            'amount_unreconciled':
                            abs(self.diferencia),
                            'amount':
                            abs(self.diferencia),
                            'journal_id':
                            journal_id.id or False,
                            'partner_id':
                            partner.id or False,
                            'product_id':
                            product_id.id
                        })]
                    })

                    account_voucher_id.proforma_voucher()
                else:
                    raise exceptions.ValidationError(
                        _(u'Error, debe seleccionar un diario venta'
                          u' o configurar un diario de venta de la compañia.'))
        else:
            super(GrpRendicionAnticipos, self).crear_recibo()
        return True
Esempio n. 6
0
 def reset_due_date(self):
     if not self.year_is_valid():
         raise exceptions.ValidationError('Year is not valid.')
     date_due = "%s-%s-05" % (self.year, self.month)
     self.date_due = date_due
Esempio n. 7
0
 def _check_email(self):
     email = self.email
     if not re.match(
             r"^[_a-z0-9-]+([.+][_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$",
             email):
         raise exceptions.ValidationError("Adres e-mail jest niepoprawny.")
Esempio n. 8
0
 def action_unconfirm(self):
     raise exceptions.ValidationError("座位数不能少于50!")
Esempio n. 9
0
 def _check_document_id_kind(self):
     if self.document_id and not self.document_id_kind:
         raise exceptions.ValidationError(
             "Podaj rodzaj dokumentu tożsamości!")
Esempio n. 10
0
 def _check_af_unicity(self):
     if self.grp_id and self.articulo_af and \
        self.search_count([('id','!=',self.id),('grp_id','=',self.grp_id.id),('articulo_af','=',self.articulo_af.id)]):
         raise exceptions.ValidationError(u'No puede seleccionar el mismo artículo de AF en más de una línea.')
Esempio n. 11
0
 def parent_required(self):
     if self.name != 'root' and not self.parent_id:
         raise exceptions.ValidationError(_('Parent channel required.'))
Esempio n. 12
0
    def _check_invoicevalue_record(self):

        for rec in self:
            if int(rec.invoicevalue) <= 0:
                raise exceptions.ValidationError('票据金额不能小于等于0!')
Esempio n. 13
0
 def _check_name(self):
     for r in self:
         if re.match('^[a-zA-Z0-9\-]+$', r.name) == None:
             raise exceptions.ValidationError('Invalid header name')
Esempio n. 14
0
    def _search_relation_id(self,
                            cr,
                            uid,
                            dummy_obj,
                            name,
                            args,
                            context=None):
        result = []
        for arg in args:
            if isinstance(arg, tuple) and arg[0] == name:
                if arg[1] not in [
                        '=', '!=', 'like', 'not like', 'ilike', 'not ilike',
                        'in', 'not in'
                ]:
                    raise exceptions.ValidationError(
                        _('Unsupported search operand "%s"') % arg[1])

                relation_type_selection_ids = []
                relation_type_selection = self\
                    .pool['res.partner.relation.type.selection']

                if arg[1] == '=' and isinstance(arg[2], (long, int)):
                    relation_type_selection_ids.append(arg[2])
                elif arg[1] == '!=' and isinstance(arg[2], (long, int)):
                    type_id, is_inverse = (relation_type_selection.browse(
                        cr, uid, arg[2],
                        context=context).get_type_from_selection_id())
                    result = OR([
                        result, [
                            ('relation_all_ids.type_id', '!=', type_id),
                        ]
                    ])
                    continue
                else:
                    relation_type_selection_ids = relation_type_selection\
                        .search(
                            cr, uid,
                            [
                                ('type_id.name', arg[1], arg[2]),
                                ('record_type', '=', 'a'),
                            ],
                            context=context)
                    relation_type_selection_ids.extend(
                        relation_type_selection.search(
                            cr,
                            uid, [
                                ('type_id.name_inverse', arg[1], arg[2]),
                                ('record_type', '=', 'b'),
                            ],
                            context=context))

                if not relation_type_selection_ids:
                    result = AND([result, [FALSE_LEAF]])

                for relation_type_selection_id in relation_type_selection_ids:
                    type_id, is_inverse = (relation_type_selection.browse(
                        cr, uid, relation_type_selection_id,
                        context=context).get_type_from_selection_id())

                    result = OR([
                        result,
                        [
                            '&', ('relation_all_ids.type_id', '=', type_id),
                            ('relation_all_ids.record_type', '=',
                             'b' if is_inverse else 'a')
                        ],
                    ])

        return result
Esempio n. 15
0
 def validate_year(self):
     if not self.year_is_valid():
         raise exceptions.ValidationError('Year is not valid.')
    def make_fuel_invoices(self):
        active_ids = self.env['fleet.vehicle.log.fuel'].browse(
            self._context.get('active_ids'))
        if not active_ids:
            return {}

        partner_ids = []
        total = 0.0
        control = 0
        for fuel in active_ids:
            if len(fuel.invoice_id) > 0:
                raise exceptions.ValidationError(
                    _('The fuel already has an invoice'))
            else:
                if (fuel.state in ('confirmed', 'closed')
                        and not fuel.invoice_paid):
                    partner_address = fuel.vendor_id.address_get(
                        ['invoice', 'contact']).get('invoice', False)
                    if not partner_address:
                        raise exceptions.ValidationError(
                            _('You must configure the home address for the'
                              ' Customer.'))
                    partner_ids.append(partner_address)
                    currency = fuel.currency_id
                    total += currency.compute(fuel.price_total,
                                              self.env.user.currency_id)
                else:
                    raise exceptions.ValidationError(
                        _('The fuels must be in confirmed / closed state'
                          ' and unpaid.'))

                invoice_id = self.env['account.invoice'].create({
                    'partner_id':
                    fuel.vendor_id.id,
                    'fiscal_position_id':
                    (fuel.vendor_id.property_account_position_id.id),
                    'reference':
                    fuel.name,
                    'currency_id':
                    fuel.currency_id.id,
                    'account_id':
                    (fuel.vendor_id.property_account_payable_id.id),
                    'type':
                    'in_invoice',
                    'invoice_line_ids': [(0, 0, {
                        'product_id':
                        fuel.base_id.fuelvoucher_product_id.id,
                        'quantity':
                        fuel.product_uom_qty,
                        'price_unit':
                        fuel.price_unit,
                        'invoice_line_tax_ids': [(6, 0, [
                            x.id for x in (fuel.base_id.fuelvoucher_product_id.
                                           gitsupplier_taxes_id)
                        ])],
                        'name':
                        fuel.base_id.fuelvoucher_product_id.name,
                        'account_id': (fuel.base_id.fuelvoucher_product_id.
                                       property_account_expense_id.id)
                    }),
                                         (0, 0, {
                                             'product_id':
                                             (fuel.base_id.ieps_product_id.id),
                                             'quantity':
                                             1.0,
                                             'price_unit':
                                             total,
                                             'name':
                                             fuel.base_id.ieps_product_id.name,
                                             'account_id':
                                             (fuel.base_id.ieps_product_id.
                                              property_account_expense_id.id)
                                         })]
                })
                fuel.write({'invoice_id': invoice_id.id})

        for partner_id in partner_ids:
            if control == 0:
                old_partner = partner_id
                current_partner = partner_id
                control = 1
            else:
                current_partner = partner_id
            if old_partner != current_partner:
                raise exceptions.ValidationError(
                    _('The fuels must be of the same customer. '
                      'Please check it.'))
            else:
                old_partner = partner_id
Esempio n. 17
0
 def validate_amount(self):
     if self.amount == 0:
         raise exceptions.ValidationError('Bill amount cannot be zero')
    def cargar_articulos(self):
        def get_uom_id(self, obj):
            """Retorna id de la unidad de medida"""

            unme_id = obj.unme_id.id
            uom_id = False

            # Si existe la unidad, retornamos su id
            self.env.cr.execute(
                "select id from product_uom where sice_uom_id = %(unme_id)s",
                {'unme_id': unme_id})

            if self.env.cr.rowcount > 0:
                res = self.env.cr.fetchone()
                uom_id = res[0]

            return uom_id

        def get_tax_id(self, obj):
            """Retorna id del impuesto correspondiente al mapeo"""

            imp_cod = obj.imp_cod
            tax_id = False

            self.env.cr.execute(
                "select imp_grp from grp_art_impuestos where cast (imp_sice as float) = %(imp_sice)s",
                {'imp_sice': imp_cod})
            if self.env.cr.rowcount > 0:
                res = self.env.cr.fetchone()
                tax_id = res[0]
            else:
                tax_id = 0

            return tax_id

        for rec in self:
            decoded_binary_data = self.csv_file.decode('base64').decode(
                'UTF-8')
            data_splitted = decoded_binary_data.split("\n")
            vals = {}
            i = 1
            if (len(data_splitted) - 1) > 100:
                raise exceptions.ValidationError(
                    u'El archivo CSV no debe contener más de 100 filas.')
            for row in data_splitted:
                if i == 1:
                    i += 1
                    continue
                row_splitted = []
                row_splitted_comma = row.split(",")
                row_splitted_dot_comma = row.split(";")
                if len(row_splitted_comma) <= 22 and len(
                        row_splitted_dot_comma) > 22:
                    row_splitted = row_splitted_dot_comma
                elif len(row_splitted_dot_comma) <= 22 and len(
                        row_splitted_comma) > 22:
                    row_splitted = row_splitted_comma
                else:
                    continue
                # if len(row_splitted) <= 1:
                #     continue
                cantidad = 0
                vals.update({
                    'name':
                    row_splitted[2],
                    'grp_sice_cod':
                    row_splitted[1],
                    'uom_desc':
                    row_splitted[5],
                    'var_desc':
                    row_splitted[6],
                    'med_var_desc':
                    row_splitted[7],
                    'pres_desc':
                    row_splitted[9],
                    'med_pres_desc':
                    row_splitted[10],
                    'uom_pres_desc':
                    row_splitted[11],
                    'color_desc': (row_splitted[12] != '') and row_splitted[12]
                    or u'NINGUNO',
                    'imp_desc':
                    row_splitted[16],
                    'stockeable':
                    row_splitted[21],
                    'cat_desc':
                    row_splitted[22],
                    'grp_objeto_del_gasto':
                    row_splitted[15],
                    'tipo_art':
                    row_splitted[13],
                })
                pool_sice_art_serv_obra = self.env['grp.sice_art_serv_obra']
                articulo = pool_sice_art_serv_obra.search([
                    ('cod', '=', vals['grp_sice_cod'])
                ])
                context = {}
                context['from_articulo_sice'] = True
                prod_uom_id = get_uom_id(self, articulo)
                prod_imp_id = get_tax_id(self, articulo)
                prod_tmp = self.env['product.template'].search([
                    ('grp_sice_cod', '=', articulo.cod)
                ])
                self._cr.execute(
                    """
                    select unme_id as id
                    from grp_sice_art_unidades_med
                    where articulo_id = %s
                """, [articulo.id])
                uom_ids = []
                for res in self._cr.dictfetchall():
                    uom_ids.append(res['id'])
                context['uom_ids'] = uom_ids
                self._cr.execute(
                    """
                    select art_im.imp_grp as id
                    from grp_sice_art_impuesto sice_im, grp_art_impuestos art_im
                    where sice_im.articulo_id = %s and cast (art_im.imp_sice as int) = sice_im.impuesto_id
                """, [articulo.id])
                tax_ids = []
                for res in self._cr.dictfetchall():
                    tax_ids.append(res['id'])
                context['tax_ids'] = tax_ids

                colors_list = [color.id for color in articulo.art_color_ids]
                _logger.info("Colores ids: %s", colors_list)
                lineas = []
                lista_variantes = []
                lista_variantes_write = []
                list_lineas = []
                attribute_id = False
                if vals['uom_desc'] == '':
                    raise exceptions.ValidationError(
                        u'No se especificó unidad de medida para el artículo %s.'
                        % vals['name'])
                if vals['cat_desc'] == '':
                    raise exceptions.ValidationError(
                        u'No se especificó categoría para el artículo %s.' %
                        vals['name'])
                desc_uom = vals['uom_desc']
                unidades_med_sice = self.env['grp.sice_unidades_med'].search([
                    ('descripcion', '=', desc_uom)
                ])
                if len(unidades_med_sice) > 0:
                    unidades_med_sice = unidades_med_sice[0]
                unidades_grp = self.env['product.uom'].search([
                    ('sice_uom_id', '=', unidades_med_sice.id)
                ])
                if len(unidades_grp) > 0:
                    unidades_grp = unidades_grp[0]
                parent_split = vals['cat_desc'].split(' /')
                categs = []
                if len(parent_split) > 1:
                    parent_name = parent_split[0]
                    child_name = vals['cat_desc'].split('/ ')[1]
                    if child_name[-1] == '\r':
                        child_name = child_name[:-1]
                    categs = self.env['product.category'].search([
                        ('parent_id.name', '=', parent_name),
                        ('name', '=', child_name)
                    ])
                else:
                    categs = self.env['product.category'].search([
                        ('name', '=', parent_split[0])
                    ])
                if len(categs) > 0:
                    categs = categs[0]
                prod_uom_id = unidades_grp.id if unidades_grp else False
                categ_id = categs.id if categs else False
                if not prod_uom_id:
                    raise exceptions.ValidationError(
                        u'La unidad de medida %s no está mapeada en GRP.' %
                        desc_uom)
                if not categ_id:
                    raise exceptions.ValidationError(
                        u'La categoría de nombre %s no existe en GRP.' %
                        vals['cat_desc'])
                tipo = 'consu'
                if vals['stockeable'] in [u'Sí', u'Si']:
                    tipo = 'product'
                elif vals['tipo_art'] in ['Servicio', 'Obra']:
                    tipo = 'service'
                if colors_list:
                    colors_list = tuple(colors_list)
                    self._cr.execute(
                        """
                        select patv.id as id, pat.id as attribute_id from product_attribute pat, product_attribute_value patv
                        where patv.attribute_id = pat.id and pat.dimension_sice
                        and patv.sice_color_id in %s
                    """, [colors_list])
                    primero = True
                    for res in self._cr.dictfetchall():
                        if primero:
                            value_id = res['attribute_id']
                            dicc = {'attribute_id': value_id}
                            primero = False
                        att_id = res['id']
                        lineas.append(att_id)
                        atv_color = self.env['product.attribute.value'].browse(
                            att_id)
                        att_values = self.env[
                            'product.attribute.value'].search([
                                ('articulo_id', '=', articulo.id)
                            ])
                        for atv in att_values:
                            values = {
                                'sice_color_id': atv_color.sice_color_id.id,
                                'med_cod_id': atv.med_cod_id.id,
                                'pres_id': atv.pres_id.id,
                                'med_cod_pres_id': atv.med_cod_pres_id.id,
                            }
                            det_var_id = False
                            if atv.det_variante_id:
                                det_var_id = atv.det_variante_id.id
                            med_cod_desc = ""
                            if atv.med_cod_id:
                                med_cod_desc = atv.med_cod_id.descripcion
                            pres_desc = ""
                            if atv.pres_id:
                                pres_desc = atv.pres_id.descripcion
                            med_cod_pres_desc = ""
                            if atv.med_cod_pres_id:
                                med_cod_pres_desc = atv.med_cod_pres_id.descripcion
                            sice_color_desc = ""
                            if atv_color.sice_color_id:
                                sice_color_desc = atv_color.sice_color_id.descripcion
                            det_var_desc = ""
                            marca = ""
                            if atv.det_variante_id:
                                det_var_desc = atv.det_variante_id.descripcion
                                med_pool = self.env['grp.sice_marca']
                                marca_obj = med_pool.search([
                                    ('cod', '=', atv.det_variante_id.marc_cod)
                                ])
                                marca = marca_obj.descripcion
                            values.update({
                                'med_cod_desc': med_cod_desc,
                                'pres_desc': pres_desc,
                                'med_cod_pres_desc': med_cod_pres_desc,
                                'sice_color_desc': sice_color_desc,
                                'marca_desc': marca,
                                'det_variante_desc': det_var_desc,
                                'det_variante_id': det_var_id,
                                'creado': False,
                                'para_crear': False,
                            })
                            variante_creada = []
                            if prod_tmp:
                                variante_creada = self.env[
                                    'grp.seleccion.variantes.lineas'].search([
                                        ('product_id', '=', prod_tmp.id),
                                        ('med_cod_desc', '=',
                                         vals['med_var_desc']),
                                        ('pres_desc', '=', vals['pres_desc']),
                                        ('med_cod_pres_desc', '=',
                                         vals['med_pres_desc']),
                                        ('sice_color_desc', '=',
                                         vals['color_desc']),
                                        ('creado', '=', True),
                                    ])
                            if vals['med_var_desc'] == values['med_cod_desc'] and\
                               vals['pres_desc'] == values['pres_desc'] and\
                               vals['med_pres_desc'] == values['med_cod_pres_desc'] and\
                               vals['color_desc'] == values['sice_color_desc'] and not len(variante_creada):
                                cantidad += 1
                                values.update({
                                    'creado': False,
                                    'para_crear': True
                                })
                            elif len(variante_creada):
                                values.update({
                                    'creado': True,
                                    'para_crear': True
                                })
                                # correccion de datos erroneos
                                campos = {
                                    'purchase_ok':
                                    True,
                                    'valuation':
                                    'real_time',
                                    'property_account_income':
                                    categs.property_account_income_categ.id,
                                    'property_account_expense':
                                    categs.property_account_expense_categ.id,
                                    'type':
                                    tipo,
                                    'uom_po_id':
                                    prod_uom_id,
                                    'uom_id':
                                    prod_uom_id,
                                    'categ_id':
                                    categ_id,
                                }
                                if (not prod_tmp.purchase_ok
                                        or prod_tmp.valuation != 'real_time' or
                                        prod_tmp.property_account_income.id !=
                                        categs.property_account_income_categ.id
                                        or prod_tmp.property_account_expense.id
                                        != categs.
                                        property_account_expense_categ.id
                                        or prod_tmp.type != tipo
                                        or prod_tmp.uom_id.id != prod_uom_id
                                        or prod_tmp.uom_po_id.id != prod_uom_id
                                        or prod_tmp.categ_id.id != categ_id):
                                    ctx = self._context.copy()
                                    ctx = dict(ctx)
                                    ctx.update({'chequeo_categorias': True})
                                    _logger.info("UPDATE PROD TEMPLATE")
                                    prod_tmp.with_context(ctx).write(campos)
                                # fin correccion de datos erroneos
                            attribute_id = atv.attribute_id.id
                            lista_variantes.append((0, 0, values))
                    dicc.update({
                        'value_ids': [(6, 0, lineas)],
                        'solo_lectura': True
                    })
                    list_lineas.append((0, 0, dicc))

                variante_id = articulo.var_id.id
                att_obj = self.env['product.attribute'].search([
                    ('sice_propiedad_id', '=', variante_id)
                ])
                # variantes_list = [med.med_cod_id.id for med in articulo.variante_ids]
                att_values = self.env['product.attribute.value'].search([
                    ('articulo_id', '=', articulo.id)
                ])
                if att_values:
                    dicc = {
                        'attribute_id': att_obj.id,
                        'value_ids': [(6, 0, att_values.ids)],
                        'solo_lectura': True
                    }
                    list_lineas.append((0, 0, dicc))

                # if vals['uom_desc'] == '':
                #     raise exceptions.ValidationError(u'No se especificó unidad de medida para el artículo %s.'
                #                                      % vals['name'])
                # if vals['cat_desc'] == '':
                #     raise exceptions.ValidationError(u'No se especificó categoría para el artículo %s.'
                #                                      % vals['name'])
                # desc_uom = vals['uom_desc']
                # unidades_med_sice = self.env['grp.sice_unidades_med'].search([('descripcion', '=', desc_uom)])
                # if len(unidades_med_sice) > 0:
                #     unidades_med_sice = unidades_med_sice[0]
                # unidades_grp = self.env['product.uom'].search([('sice_uom_id', '=', unidades_med_sice.id)])
                # if len(unidades_grp) > 0:
                #     unidades_grp = unidades_grp[0]
                # parent_split = vals['cat_desc'].split(' /')
                # categs = []
                # if len(parent_split) > 1:
                #     parent_name = parent_split[0]
                #     child_name = vals['cat_desc'].split('/ ')[1]
                #     categs = self.env['product.category'].search([('parent_id.name', '=', parent_name),
                #                                                   ('name', '=', child_name)])
                # else:
                #     categs = self.env['product.category'].search([('name', '=', parent_split[0])])
                # if len(categs) > 0:
                #     categs = categs[0]
                # prod_uom_id = unidades_grp.id if unidades_grp else False
                # categ_id = categs.id if categs else False
                # if not prod_uom_id:
                #     raise exceptions.ValidationError(u'La unidad de medida %s no está mapeada en GRP.'
                #                                      % desc_uom)
                # if not categ_id:
                #     raise exceptions.ValidationError(u'La categoría de nombre %s no existe en GRP.'
                #                                      % vals['cat_desc'])
                # tipo = 'consu'
                # if vals['stockeable'] in [u'Sí', u'Si']:
                #     tipo = 'product'
                # elif vals['tipo_art'] in ['Servicio', 'Obra']:
                #     tipo = 'service'
                campos = {
                    'is_multi_variants':
                    True,
                    'type':
                    tipo,
                    'cost_method':
                    'real',
                    'uom_po_id':
                    prod_uom_id,
                    'uom_id':
                    prod_uom_id,
                    'categ_id':
                    categ_id,
                    'grp_objeto_del_gasto':
                    articulo.odg,
                    'grp_sice_cod':
                    articulo.cod,
                    'name':
                    articulo.descripcion,
                    'description':
                    "Nombre SICE: " + articulo.descripcion,
                    'attribute_line_ids':
                    list_lineas,
                    'seleccion_variantes_ids':
                    lista_variantes,
                    'attribute_id':
                    attribute_id,
                    'sale_ok':
                    False,
                    'purchase_ok':
                    True,
                    'valuation':
                    'real_time',
                    'property_account_income':
                    categs.property_account_income_categ.id,
                    'property_account_expense':
                    categs.property_account_expense_categ.id,
                }
                impuestos = self.env['account.tax'].search([
                    ('name', '=', vals['imp_desc'])
                ])
                if len(impuestos) > 0:
                    impuestos = impuestos[0]
                if impuestos.id:
                    campos['supplier_taxes_id'] = [(6, 0, [impuestos.id])]
                else:
                    raise exceptions.ValidationError(
                        u'El impuesto de nombre %s no existe en GRP.' %
                        vals['imp_desc'])
                # property_account_income = categs.property_account_income_categ.id
                # property_account_expense = categs.property_account_expense_categ.id
                # duda: supplier_taxes_id para tomarlo de columna Impuesto busco por descripcion ?
                # if prod_imp_id:
                #     campos.update({'supplier_taxes_id': [(6, 0, [prod_imp_id])]})
                context['hide_grp_buttons'] = True
                context['creacion_inicial'] = True
                context['cargar_variantes'] = False
                context['generar_variantes'] = True
                context['chequeo_categorias'] = True
                if not prod_tmp:
                    created_id = self.env['product.template'].with_context(
                        context).create(campos)
                    # context['creacion_inicial'] = False
                    # created_id.with_context(context).create_variant_ids()
                else:
                    context['creacion_inicial'] = False
                    pool_seleccion_variantes = self.env[
                        'grp.seleccion.variantes.lineas']
                    variantes = pool_seleccion_variantes.search([
                        ('product_id', '=', prod_tmp.id),
                        ('para_crear', '=', False),
                        ('med_cod_desc', '=', vals['med_var_desc']),
                        ('pres_desc', '=', vals['pres_desc']),
                        ('med_cod_pres_desc', '=', vals['med_pres_desc']),
                        ('sice_color_desc', '=', vals['color_desc']),
                    ])
                    if len(variantes) > 0:
                        pool_seleccion_variantes.browse(variantes.ids).write({
                            'para_crear':
                            True,
                            'creado':
                            False
                        })
                        prod_tmp.with_context(context).create_variant_ids()
        return True
Esempio n. 19
0
 def _check_name(self):
     for rec in self:
         product = self.search([('product_id', '=', rec.product_id.id)])
         if product and len(product.ids) > 1:
             raise exceptions.ValidationError(
                 _(u'Solo debe existir un registro por producto.'))
Esempio n. 20
0
 def _check_employee(self):
     if self.agent_type == 'salesman' and not self.employee:
         raise exceptions.ValidationError(
             _("There must one (and only one) employee linked to this "
               "partner. To do this, go to 'Human Resources' and check "
               "'Employees'"))
Esempio n. 21
0
 def _check_nip(self):
     weights = (6, 5, 7, 2, 3, 4, 5, 6, 7)
     self._clean_field_value('nip')
     if self.nip and not self._is_gov_id_valid(self.nip, weights):
         raise exceptions.ValidationError("Niepoprawny NIP.")
Esempio n. 22
0
 def _check_skills_no(self):
     max_skills = int(self.env['ir.config_parameter'].get_param('bestja_offers.max_skills'))
     if len(self.skills) > max_skills:
         raise exceptions.ValidationError("Wybierz maksymalnie {} umiejętności!".format(max_skills))
Esempio n. 23
0
    def action_move_create(self):
        account_move_obj = self.env['account.move']
        account_move_line_obj = self.env['account.move.line']
        cur_obj = self.pool.get('res.currency')
        for rec in self:
            if not rec.employee_id.address_home_id:
                raise exceptions.ValidationError(
                    _(u'El empleado debe tener una dirección de casa.'))
            if not rec.employee_id.address_home_id.supplier_advance_account_id.id or not rec.employee_id.address_home_id.customer_advance_account_id.id:
                raise exceptions.ValidationError(
                    _(u'El empleado debe tener las cuentas anticipos de proveedores y clientes establecida en su dirección de casa.'
                      ))
            if len(rec.line_ids) > 0:
                # create the move that will contain the accounting entries
                account_move_dict = rec.account_move_get(rec.id)
                account_move_dict.update(
                    {'operating_unit_id': rec.operating_unit_id.id})
                move_id = account_move_obj.create(account_move_dict)
                company_currency = rec.company_id.currency_id.id
                diff_currency_p = rec.currency_id.id <> company_currency
                currency_id = False
                amount = rec.amount
                amount_currency = False
                if diff_currency_p:
                    amount_currency = rec.amount * -1
                    currency_id = rec.currency_id.id
                    amount = cur_obj.compute(self._cr, self._uid, currency_id,
                                             company_currency, rec.amount,
                                             self._context)
                for linea in rec.line_ids:
                    property_obj = self.pool.get('ir.property')
                    if rec.solicitud_anticipos_id:
                        acc = linea.account_concept_id
                    elif linea.product_id:
                        acc = linea.product_id.property_account_expense
                        if not acc:
                            acc = linea.product_id.categ_id.property_account_expense_categ
                        if not acc:
                            raise exceptions.ValidationError(
                                _(u'No se ha encontrado una cuenta de compras para el producto %s (o para su categoría). Por favor, configure una.'
                                  ) % (linea.product_id.name))
                    else:
                        acc = property_obj.with_context(
                            force_company=linea.company_id.id).get(
                                'property_account_expense_categ',
                                'product.category')
                    if not acc:
                        raise exceptions.ValidationError(
                            _(u'No se ha podido identificar una cuenta para generar la información contable'
                              ))

                    total_amount_currency = False
                    total_amount = linea.total_amount
                    if diff_currency_p:
                        total_amount_currency = linea.total_amount
                        total_amount = cur_obj.compute(self._cr, self._uid,
                                                       currency_id,
                                                       company_currency,
                                                       linea.total_amount,
                                                       self._context)
                    account_move_line_obj.create({
                        'move_id':
                        move_id.id,
                        'name':
                        '/',
                        'partner_id':
                        rec.employee_id.address_home_id.id or False,
                        'amount_currency':
                        total_amount_currency,
                        'currency_id':
                        currency_id,
                        'account_id':
                        acc.id,
                        'credit':
                        False,
                        'debit':
                        total_amount,
                        'operating_unit_id':
                        rec.operating_unit_id.id
                    })
                if rec.doc_type == 'rendicion_anticipo':
                    _account_id = rec.employee_id.address_home_id.customer_advance_account_id.id
                else:
                    _account_id = rec.employee_id.address_home_id.supplier_advance_account_id.id

                if not _account_id:
                    raise exceptions.ValidationError(
                        _(u'No se ha podido identificar una cuenta para generar la información contable'
                          ))

                account_move_line_obj.create({
                    'move_id':
                    move_id.id,
                    # 28/12/2018 ASM renombrar sequence (nombre reservado) a x_sequence
                    # 'name': rec.sequence,
                    'name':
                    rec.x_sequence,
                    #
                    'account_id':
                    _account_id,
                    'debit':
                    False,
                    'credit':
                    amount,
                    'partner_id':
                    rec.employee_id.address_home_id.id or False,
                    'amount_currency':
                    amount_currency > 0 and amount_currency * -1
                    or amount_currency,
                    'currency_id':
                    currency_id,
                    'operating_unit_id':
                    rec.operating_unit_id.id
                })

                dict_write = {
                    'account_move_id': move_id.id,
                    'show_move_line_button': False
                }
                if rec.diferencia == 0:
                    dict_write.update({'state': 'paid'})
                else:
                    rec.crear_recibo()
                rec.write(dict_write)

            else:
                raise exceptions.ValidationError(
                    _(u'Error, para generar apuntes contables'
                      u' de la anticipos de fondos primero debe crear líneas'))
            return True
Esempio n. 24
0
 def _check_wishes_no(self):
     max_wishes = int(self.env['ir.config_parameter'].get_param('bestja_offers.max_wishes'))
     if len(self.wishes) > max_wishes:
         raise exceptions.ValidationError("Wybierz maksymalnie {} obszarów działania!".format(max_wishes))
Esempio n. 25
0
 def _check_instructor_not_in_attendees(self):
     if self.instructor_id and self.instructor_id in self.attendee_ids:
         raise exceptions.ValidationError(
             "A session's instructor can't be an attendee")
Esempio n. 26
0
 def _check_vacancies(self):
     if self.vacancies <= 0:
         raise exceptions.ValidationError("Liczba wakatów musi być większa od 0!")
Esempio n. 27
0
 def button_cancelar_pago(self, cr, uid, ids, context=None):
     invoices = self.read(cr, uid, ids, ['fondo_rotarios'])
     for invoice in invoices:
         if invoice['fondo_rotarios'] == True:
             raise exceptions.ValidationError(_(u'Este documento está en un documento 3-en1-Fondo rotatorio. No es posible cancelarlo.'))
     return super(account_invoice_fr, self).button_cancelar_pago(cr, uid, ids, context)
Esempio n. 28
0
 def check_vat_prorrate_percent(self):
     for line in self:
         if not (0 < line.vat_prorrate_percent <= 100):
             raise exceptions.ValidationError(
                 _('VAT prorrate percent must be between 0.01 and 100'))
Esempio n. 29
0
    def _action_create_other_receivable_voucher(self):
        Config = self.env['dym.branch.config']
        config_id = self.env['dym.branch.config'].search(
            [('branch_id', '=', self.branch_id.id)], limit=1)

        if not config_id.dym_incentive_income_account:
            raise exceptions.ValidationError((
                "Cabang %s tidak memiliki akun pendapatan atas program Incentive. Silahkan setting di Branch Config"
                % (self.inter_branch_id.name)))

        if not config_id.dym_incentive_income_account.tax_ids:
            raise exceptions.ValidationError((
                "Akun %s %s tidak memiliki default pajak PPN, silahkan setting dulu di form account: Accounting > Confifuration > Accounts > Accounts."
                % (config_id.dym_incentive_income_account.code,
                   config_id.dym_incentive_income_account.name)))

        if not config_id.dym_incentive_income_account.withholding_tax_ids:
            raise exceptions.ValidationError((
                "Akun %s %s tidak memiliki default pajak PPH, silahkan setting dulu di form account: Accounting > Confifuration > Accounts > Accounts."
                % (config_id.dym_incentive_income_account.code,
                   config_id.dym_incentive_income_account.name)))

        if len(config_id.dym_incentive_income_account.tax_ids) > 1:
            raise exceptions.ValidationError((
                "Akun %s %s memiliki lebih dari 1 jenis pajak PPN, silahkan setting satu saja di form account: Accounting > Confifuration > Accounts > Accounts."
                % (config_id.dym_incentive_income_account.code,
                   config_id.dym_incentive_income_account.name)))

        if len(config_id.dym_incentive_income_account.withholding_tax_ids) > 1:
            raise exceptions.ValidationError((
                "Akun %s %s memiliki lebih dari 1 jenis pajak PPH, silahkan setting satu saja di form account: Accounting > Confifuration > Accounts > Accounts."
                % (config_id.dym_incentive_income_account.code,
                   config_id.dym_incentive_income_account.name)))

        if not self.account_id.tax_ids:
            raise exceptions.ValidationError((
                "Akun %s %s tidak memiliki default pajak PPN, silahkan setting dulu di form account: Accounting > Confifuration > Accounts > Accounts."
                % (self.account_id.code, self.account_id.name)))

        if not self.account_id.withholding_tax_ids:
            raise exceptions.ValidationError((
                "Akun %s %s tidak memiliki default pajak PPH, silahkan setting dulu di form account: Accounting > Confifuration > Accounts > Accounts."
                % (self.account_id.code, self.account_id.name)))

        if len(self.account_id.tax_ids) > 1:
            raise exceptions.ValidationError((
                "Akun %s %s memiliki lebih dari 1 jenis pajak PPN, silahkan setting satu saja di form account: Accounting > Confifuration > Accounts > Accounts."
                % (self.account_id.code, self.account_id.name)))

        if len(self.account_id.withholding_tax_ids) > 1:
            raise exceptions.ValidationError((
                "Akun %s %s memiliki lebih dari 1 jenis pajak PPH, silahkan setting satu saja di form account: Accounting > Confifuration > Accounts > Accounts."
                % (self.account_id.code, self.account_id.name)))

        WHT = self.env['account.tax.withholding']
        analytic_1, analytic_2, analytic_3, analytic_4 = self.env[
            'account.analytic.account'].get_analytical(self.inter_branch_id,
                                                       self.inter_division,
                                                       False, 4, 'Sales')
        periode_name = datetime.strftime(
            datetime.strptime(self.value_date, '%Y-%m-%d'), "%B %Y") or None
        voucher_dr_line = [[
            0, 0, {
                'account_id':
                config_id.dym_incentive_income_account.id,
                'date_original':
                self.value_date,
                'date_due':
                self.value_date,
                'amount_original':
                self.total_dpp,
                'amount_unreconciled':
                self.total_dpp,
                'amount':
                self.total_dpp,
                'currency_id':
                config_id.dym_incentive_income_account.currency_id.id or False,
                'type':
                'cr',
                'name':
                self.description,
                'reconcile':
                True,
                'analytic_1':
                analytic_1,
                'analytic_2':
                analytic_2,
                'analytic_3':
                analytic_3,
                'account_analytic_id':
                analytic_4,
            }
        ]]
        withholding_ids = [[
            0, 0, {
                'tax_withholding_id':
                config_id.dym_incentive_income_account.withholding_tax_ids[0].
                id,
                'tax_base':
                self.total_dpp,
                'amount':
                self.total_dpp * config_id.dym_incentive_income_account.
                withholding_tax_ids[0].amount,
                'date':
                self.value_date,
            }
        ]]
        analytic_1, analytic_2, analytic_3, analytic_4 = self.env[
            'account.analytic.account'].get_analytical(self.branch_id, 'Umum',
                                                       False, 4, 'General')
        voucher_data = {
            'branch_id':
            self.branch_id.id,
            'division':
            self.division,
            'inter_branch_id':
            self.inter_branch_id.id,
            'inter_branch_division':
            self.inter_division,
            'pay_now':
            'pay_later',
            'date':
            self.value_date,
            'date_due':
            self.value_date,
            'reference':
            self.name,
            'user_id':
            self.env.user.id,
            'company_id':
            self.branch_id.company_id.id,
            'partner_id':
            self.partner_id.id,
            'journal_id':
            config_id.dym_incentive_allocation_journal.id,
            'amount':
            self.total_cair,
            'net_amount':
            self.total_cair,
            'account_id':
            config_id.dym_incentive_allocation_journal.
            default_debit_account_id.id,
            'state':
            'draft',
            'type':
            'sale',
            'analytic_2':
            analytic_2,
            'analytic_3':
            analytic_3,
            'analytic_4':
            analytic_4,
            'line_dr_ids':
            voucher_dr_line,
            'line_cr_ids': [],
            'withholding_ids':
            withholding_ids if self.batch_id.use_withholding else False,
            'tax_id':
            config_id.dym_incentive_income_account.tax_ids[0].id,
        }
        voucher_id = self.env['account.voucher'].create(voucher_data)
        voucher_id.validate_or_rfa_credit()
        voucher_id.signal_workflow('approval_approve')
        self.voucher_id = voucher_id.id
        return True
 def check_amount(self):
     if self.amount_advance <= 0:
         raise exceptions.ValidationError(
             _("Amount of advance must be "
               "positive."))