logo
down
shadow

add custom field that I already created to Invoice in OpenERP


add custom field that I already created to Invoice in OpenERP

By : Jared Daniel Steele
Date : November 18 2020, 11:13 AM
fixed the issue. Will look into that further As @Hardik suggests you have to use related field in you account.invoice model. I personally find this weird as it would be much more intuitive, flexible and powerful to write just but this doesn't work in OpenERP.
Instead, you have to declare a new field in the 'account.invoice' model which takes the value from the related 'res.partner' model. In an appropriate place in your model extend the 'account.invoice' model as you did for 'res.partner'
code :
class invoice(osv.osv):
    _inherit = 'account.invoice'
    _columns = {
           'rnc_ced': fields.related('partner_id',
                                     'clientes_rnc_ced',
                                     type='char', size=12,
                                     string='RNC o Cédula'),
    }

invoice()
<field name="rnc_ced">


Share : facebook icon twitter icon
invoice in openerp

invoice in openerp


By : Samantha Johnson
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , You are trying to compare an integer with a boolean (as indicated by the error).
Since this is SQL 0 (the number) doesn't equal false (a boolean type).
OpenERP 7 API invoice validation and payment

OpenERP 7 API invoice validation and payment


By : OldCoder1894
Date : March 29 2020, 07:55 AM
To fix this issue Hi i figured out how to validate payment to an invoice automatically via XML-RPC using php.
This how openERP invoice workflow works for the payment.
code :
<?php

error_reporting(1);
/*
 * TODO
 * Improve on handling of server responses. Success and Failures
 */
date_default_timezone_set('Europe/Moscow');
include_once("openerp_models.php");
/////////////////////////////////////////////////////////////////////
//confirm that a username and password is set 
if (isset($_SERVER['PHP_AUTH_USER']) && $_SERVER['PHP_AUTH_PW']) {

    //password and username -- Basic Authentication
    $username = $_SERVER['PHP_AUTH_USER'];
    $password = $_SERVER['PHP_AUTH_PW'];

    ///important parameters
    $phone_no = $_REQUEST['sender_phone']; //get the mobile number. Use this number to get the partner information.
    $amount = $_REQUEST['amount']; // get amount from url
    $amount_again = $_REQUEST['amount'];  //this will be displayed to the paying client. $amount above is reduced to zero hence
                                          //we create another amount variable to show the customer with success message.
    $payment_ref = $_REQUEST['k2_transaction_id']; // get this from url
    $firstname = $_REQUEST['first_name'];
    $lastname = $_REQUEST['last_name'];
    $middlename = $_REQUEST['middle_name'];
    $service_name = $_REQUEST['service_name'];
    $business_number = $_REQUEST['business_number'];
    $transaction_reference = $_REQUEST['transaction_reference'];
    $internal_transaction_id = $_REQUEST['internal_transaction_id'];
    $transaction_timestamp = $_REQUEST['transaction_timestamp'];
    $transaction_type = $_REQUEST['transaction_type'];
    $account_number = $_REQUEST['account_number'];
    $currency = $_REQUEST['currency'];
    $signature = $_REQUEST['signature'];



    //openerp instance, pass login,password,dbname and serverURL 
    $kengen_model = new OpenERPXmlrpc($username, $password, 'copia_training_db', 'http://127.0.0.1:8069/xmlrpc/');
    /* TODO UNCOMMENT THIS CODE FOR ACTUAL TESTING WITH KOPOKOPO SERVER
     * We will then authorize kopokopo to continue with record creation. But before that,
     * we should make sure that the request is actually coming from kopokopo using the signature value sent.
     * To learn more see https://app.kopokopo.com/push_api
     *
    //set up base string
    $base_string = "account_number=".$account_number."&amount=".$amount."&business_number=".$business_number."&"
            . "currency=".$currency."&first_name=".$firstname."&internal_transaction_id=".$internal_transaction_id."&"
            . "last_name=".$lastname."&middle_name=".$middlename."&sender_phone=".$phone_no."&service_name=".$service_name."&transaction_reference=".$transaction_reference."&"
            . "transaction_timestamp=".$transaction_timestamp.""
            . "transaction_type=".$transaction_type." "; 
    //get the symmetric key from table keys.api. This key should be copied from Your KopoKopo Account

    $get_key =  $kengen_model->search('keys.api', 'provider_name', '=', 'KopoKopo') ;  

    $key_id = $get_key[0];

    $key_value = '' ;
    //we read
          $read_keys = $kengen_model->read('keys.api', [$key_id]);
          //loop 
            foreach ($read_keys as $keys => $values) {
            $value = $values->scalarval();
           // print_r($value);
            //  print '<br/>';
            //$myarray [] = array($value['name']->scalarval());
            $key_value = $value['key_value']->scalarval();


        }
   // print $key_value; exit;
    //data to use
    $hash_data = hash_hmac('sha256', $base_string, $key_value, true);
    //generate our own signature to compare with
    $signature_to_test = base64_encode($hash_data) ;

    ///test if the parameter $signature passed by KopoKopo is equal to $signature_to_test 
   // print $signature_to_test; 

     * TODO, DO the actual testing with Real KEY_VALUE and Request from kopokopo and only allow execution if 
     *  $signature_to_test = $signature else return an access denied status
     */

    /////////////////////////////////////////
    /* We retrieve the payment journal for kopokopo. We will 
     * use the journal code to retrieve the journal id. 
     * The code for kopokopo should be KPKPJ
     */
    $get_jrnl_code = $kengen_model->search('account.journal', 'code', '=', 'KPKPJ') ;
    $journal_id = $get_jrnl_code[0]; //kopokopo journal
    /*
     * We retrieve the account_id to pay to. This code is code for KopoKopo Account 
     * should be static i.e. 2040 is the account unless otherwise specified.
     */
    $get_acc_code = $kengen_model->search('account.account', 'code', '=', '2040') ;
    $account_id = $get_acc_code[0]; //kopokopo account
    //for this record to appear on list of customer payment
    $type = 'receipt';
    //

    /* TODO
     * after a successful login, we must authorize this user. We do this to make sure that 
     * the request if coming from kopokopo server.
     */

    //now search for the partner using phone/mobile number parameter
    $search_partner = $kengen_model->search('res.partner', 'phone', '=', $phone_no);
    //check to make sure that the customer exists
    //create an array
    $ids = array();
    //loop through the $search content and assign its contents to the $ids
    for ($i = 0; $i <= count($search_partner); $i++) {
        //   print $search_partner[$i];
        $ids [] = $search_partner[$i];
    }

    // if a user exist we continue processing
    if (count($ids[0]) > 0) {
        //perform a read, by picking the first item on the array
        $read = $kengen_model->read('res.partner', [$ids[0]]);
        // print_r($read);
        $myarray = null;

        $client_name = '';
        //this foreach loop with only loop once. hence just retrieve the client name and amount saved
        // in openerp 

        foreach ($read as $keys => $values) {
            $value = $values->scalarval();

            //  print '<br/>';
            //$myarray [] = array($value['name']->scalarval());
            $client_name = $value['name']->scalarval();
        }
        /////////////////////////////////////////////////////
        //get invoices, pass partner_id and invoice status which is open for unpaid invoices
        //get invoices to retrieve the journal id   
        $get_invoices = $kengen_model->getPartnetInvoices('account.voucher', $ids[0], 'open');
        $retrieved_pay_account_id = 0;
        $pay_journal_id = 0;
        $period_id = 0;
        foreach ($get_invoices as $keys => $values) {
            $value = $values->scalarval();

            $retrieved_pay_account_id = $value[4]->scalarval();
            $pay_journal_id = $value[5]->scalarval();
            $period_id = $value[6]->scalarval();
            $move_id = $value[7]->scalarval();
        }
        //  print $retrieved_account_id; 
        /////////////////////////////////////////////////////
        //fields to create
        $account_voucher_fields = array(
            'partner_id' => $ids[0],
            'amount' => $amount,
            'reference' => $payment_ref,
            'journal_id' => $journal_id,
            'account_id' => $account_id,
            //   'move_id' => $move_id ,
            // 'journal_id'=> $retrieved_journal_id, 
            'type' => $type);
        //voucher payment
            $create_kopokopo_payment = $kengen_model->createRecord($account_voucher_fields, 'account.voucher');
        //we get the total amount of invoice available for this customer.
        $total_invoices_amount = $kengen_model->getPartnetInvoices('account.voucher', $ids[0], 'open');
        $invoice_totals = 0;
        foreach ($total_invoices_amount as $keys => $values) {
            $value = $values->scalarval();
            $invoice_totals += $value[3]->scalarval();
            ///
        }

        //  print 'invoice totals is '.$invoice_totals ;
        //voucher line payment
        //we will retrieve all invoices available for this partner
        //get invoices, pass partner_id and invoice status which is open for unpaid invoices
        $invoices = $kengen_model->getPartnetInvoices('account.voucher', $ids[0], 'open');
        //loop through available invoices. Remember that a customer can have more than one open invoice
        $total_credit = 0;
        foreach ($invoices as $keys => $values) {
            $value = $values->scalarval();
            $number = $value[1]->scalarval();
            $invoice_amount_to_pay = $value[3]->scalarval();
            /*
             *  To undestand how this code works look at account.voucher model in openerp
             *  function recompute_voucher_lines(). This openerp function calculates voucher lines given
             * a particular payment.
             */
            $min_amount = min($invoice_amount_to_pay, $amount);
            //
          /*  print 'x';
            print 'on existing invoices in ELSE IF >>>' . ($min_amount);
            print '<br/>';
            print 'amount_unreconciled is >>>' . ($invoice_amount_to_pay);
            print '<br/>';
            print 'total_credit is >>>' . $amount;
            print '<br/>'; */
            ///
             //reduce amount paid
            $amount -= $min_amount;
            //convert amount into int
            $amount_to_allocate = intval($min_amount);
            // print $amount_total ;
            ///get invoice move line ids
            $new_number = str_replace('/', '', $number); //convert the invoice line
            $move_ids = $kengen_model->search('account.move.line', 'ref', '=', $new_number);
            /////
            $account_voucher_line_fields = array(
                'partner_id' => $ids[0],
                'voucher_id' => $create_kopokopo_payment, //last id inserted in account.voucher
                'account_id' => $retrieved_pay_account_id,
                'move_line_id' => $move_ids[0],
                'amount' => $amount_to_allocate,
                'type' => 'cr',
                'name' => $number,);
            //////
                $create_kopokopo_line_payment = $kengen_model->createRecord($account_voucher_line_fields, 
                       'account.voucher.line'); 
        }
        /*
         * we validate the payment. We access method button_proforma_voucher declared in model account.voucher
         * This methods validates an invoice payment and does reconcilation process for us if the user has paid
         * fully else the method reconciles invoice partially.
         */
        $validate_voucher_payment = $kengen_model->call_function_func('account.voucher', 
          'button_proforma_voucher', array($create_kopokopo_payment));  



        //customer found. Return a json response for KopoKopo
        $message = "Thank you " . $client_name . " for your payment of Ksh " . $amount_again . ". We value your business";
        // see doc @ https://app.kopokopo.com/push_api
        $success_response = array("status" => "01", "description" => "Accepted",
            "subscriber_message" => $message);
        echo json_encode($success_response);
        return json_encode($success_response);
    }

    // else we return a json_response with error message
    else {
        //customer not found. Return a json response for KopoKopo
        // see doc @ https://app.kopokopo.com/push_api
        $error_response = array("status" => "02", "description" => "Account not found");
        echo json_encode($error_response);
        return json_encode($error_response);
    }
} else {
    header('WWW-Authenticate: Basic realm="Copia ERP"');
    header('HTTP/1.0 401 Unauthorized');
    print 'Access Denied';
    exit();
}

?>
How to get sale order field value in invoice from OpenERP

How to get sale order field value in invoice from OpenERP


By : Alvaro Sacari
Date : March 29 2020, 07:55 AM
To fix this issue As @archetipo said, best way is create a new own custom module.
Given example of your solution, try this,
code :
class account_invoice_line(osv.Model):
    _inherit = 'account.invoice.line'
    _columns = {
        'purchase_order': fields.char('Purchase Order'),
        'amt_total': fields.float('Amout Total'),
    }
<record id="view_account_order_extend1_form" model="ir.ui.view">
    <field name="name">account.order.form.price.extend</field>
    <field name="model">account.invoice</field>
    <field name="inherit_id" ref="account.invoice_form" />
    <field name="arch" type="xml">
        <xpath expr="//page[@string='Invoice Lines']/field[@name='invoice_line']/tree[@string='Invoice Lines']/field[@name='name']" position="after">
            <field name="purchase_order"/>
            <field name="amt_total"/>
        </xpath>
    </field>
</record>
How to copy the value of a custom field from sale order to invoice while creating invoice in odoo

How to copy the value of a custom field from sale order to invoice while creating invoice in odoo


By : SBlancher
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further I have a custom field in sale.order.line as , Override _prepare_invoice_line method from sale.py in sale module.
code :
    @api.multi
    def _prepare_invoice_line(self, qty):
        ...

        ...
        res = {
            'name': self.name,
            'sequence': self.sequence,
            'origin': self.order_id.name,
            'account_id': account.id,
            'price_unit': self.price_unit,
            'quantity': qty,
            'discount': self.discount,
            'uom_id': self.product_uom.id,
            'product_id': self.product_id.id or False,
            'invoice_line_tax_ids': [(6, 0, self.tax_id.ids)],
            'account_analytic_id': self.order_id.project_id.id,
            'scheme' : self.scheme.id
        }
        return res
Stripe Invoice. Start/created and End date are all the same for first invoice

Stripe Invoice. Start/created and End date are all the same for first invoice


By : Matthew Dubois
Date : March 29 2020, 07:55 AM
I wish this helpful for you The current_period_end and current_period_start corresponds to the period the invoice is for. As a rule on Stripe's end, the invoice is always for the "previous" period while the line item for the subscription is always for the new month.
This means that if you have a monthly subscription on the 1st of the month, the invoice on the 1st of November will be for the 1st of October until the 1st of November while the line item for the subscription will be for 1st of November to the 1st of December.
Related Posts Related Posts :
  • No address associated with hostname using vagrant
  • 2 way data-binding between a polymer component and a model?
  • How can I rename an already published app in the Windows Dev Center?
  • Using Chef 12 , Chef Client unable to connect to chef Server
  • GCM notification not working (GoogleCloudMessaging)
  • Measured GFLOPS is greater then theoretical GFLOPS
  • Progress ABL - strip and add to temp table
  • Errors occuring when make-ing Aircrack-ng on raspberry pi
  • Detecting Handedness from Device Use
  • Query a manual list of data items
  • Similar to pivot - Windows 8.1 Desktop app
  • CKEDITOR And Styles configuration with only toolbar
  • Segmentation fault due to data alignment issue on MIC
  • how to connect a Java app ( java code ) to cloudant?
  • How to download a file/folder from remote (openshift) to local system
  • Where can i find customeditors in JBPM 6
  • Pig get distinct rows with counts
  • In Flex when is yylineno updated?
  • How does a semantic reasoner for protegé is made?
  • how to stop another rows to be select after select a row in uitableview
  • Setup cmd.exe parameter when starting ConEmu
  • WPF how to get the same visual size in different devices
  • How to convert tiff to searchable pdf using alfresco and tesseact?
  • Intel Media SDK: Regarding mfxIMPL Usage
  • How to pass values to SOAP service using web service consumer?
  • Post image base64 from iOS to twitter using request.js
  • I have installed chef server, client version 12.0.1 and 12.0.3 respectively but unable to authenticate to chef server
  • Minifying and publishing CSS and JavaScript using Visual Studio 2013 and LESS
  • Can't deploy kitchensink example
  • Facing issue in mule testing
  • db2 explain result about lock size
  • Make Firebug NOT autocomplete
  • Blank Space at bottom of Polymer Paper Dialog
  • How do you initialize application state at startup and access it from controllers in MVC 6?
  • can you help when to use field and when to use parameter and variable in jasper?
  • What are Talend change data capture's pluses and deltas in a production EAI+big data integration scenario?
  • Tree traversal in Rust vs Borrow Checker
  • how sensiya SDK distinct motion sitting and driving?
  • Test Dropbox webhooks implementation with self-signed certificate?
  • Custom axis labels for Core Plot
  • Using CLLocationManager in SpringBoard, but got the error with:depending on legacy on-demand authorization, which is not
  • retrieving selected documents in couchdb
  • How to unroll client side bundle
  • Why JPanel doesn't have all the lines in my app?
  • make ctrl+enter add semicolon to the end of the line
  • How to test low-bit ambient and burn-in protection when making watch faces?
  • What is causing this error in changing the default music font in a Lilypond document?
  • Using environment variables in POST payload
  • Use a custom helper in Middleman Frontmatter
  • LinkedIn r_basicprofile and r_fullprofile scope fields and why are both "redundant"?
  • Disconnecting 2 vertical "lines" with glDrawArrays GL_TRIANGLE_STRIP
  • Slow apigee query when using geolocation with wildcard search
  • Allocator replacement check
  • Javafx 8 how to make mouse cursor invisible?
  • Can you use OpenID Connect without obtaining OAuth credentials?
  • Appium send_keys overwritting previous text
  • Where do I find my google places 'place_id'?
  • Parse.com Stripe: Creating a charge that is not captured
  • Custom Vibe sequence in Pebble.js?
  • reuse property in my own owl ontology but change domain/range
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org